Skip to content

The Free Software Media System - Server Backend & API

Merge branch 'master' into segment-deletion

Dominik17f1e8d19b1f
diff --cc Jellyfin.Api/Controllers/DynamicHlsController.cs
index 81d77663e9,09cf7303e7..86be68004d
--- a/Jellyfin.Api/Controllers/DynamicHlsController.cs
+++ b/Jellyfin.Api/Controllers/DynamicHlsController.cs
@@@ -1452,377 -1468,377 +1468,397 @@@ public class DynamicHlsController : Bas
if (System.IO.File.Exists(segmentPath))
{
job = _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
- _logger.LogDebug("returning {0} [it exists, try 1]", segmentPath);
+ transcodingLock.Release();
+ released = true;
+ _logger.LogDebug("returning {0} [it exists, try 2]", segmentPath);
return await GetSegmentResult(state, playlistPath, segmentPath, segmentExtension, segmentId, job, cancellationToken).ConfigureAwait(false);
}
-
- var transcodingLock = _transcodingJobHelper.GetTranscodingLock(playlistPath);
- await transcodingLock.WaitAsync(cancellationToken).ConfigureAwait(false);
- var released = false;
- var startTranscoding = false;
-
- try
+ else
{
- if (System.IO.File.Exists(segmentPath))
+ var currentTranscodingIndex = GetCurrentTranscodingIndex(playlistPath, segmentExtension);
+ var segmentGapRequiringTranscodingChange = 24 / state.SegmentLength;
+
+ if (segmentId == -1)
{
- job = _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
- transcodingLock.Release();
- released = true;
- _logger.LogDebug("returning {0} [it exists, try 2]", segmentPath);
- return await GetSegmentResult(state, playlistPath, segmentPath, segmentExtension, segmentId, job, cancellationToken).ConfigureAwait(false);
+ _logger.LogDebug("Starting transcoding because fmp4 init file is being requested");
+ startTranscoding = true;
+ segmentId = 0;
}
- else
+ else if (currentTranscodingIndex is null)
{
- var currentTranscodingIndex = GetCurrentTranscodingIndex(playlistPath, segmentExtension);
- var segmentGapRequiringTranscodingChange = 24 / state.SegmentLength;
-
- if (segmentId == -1)
- {
- _logger.LogDebug("Starting transcoding because fmp4 init file is being requested");
- startTranscoding = true;
- segmentId = 0;
- }
- else if (currentTranscodingIndex == null)
- {
- _logger.LogDebug("Starting transcoding because currentTranscodingIndex=null");
- startTranscoding = true;
- }
- else if (segmentId < currentTranscodingIndex.Value)
- {
- _logger.LogDebug("Starting transcoding because requestedIndex={0} and currentTranscodingIndex={1}", segmentId, currentTranscodingIndex);
- startTranscoding = true;
- }
- else if (segmentId - currentTranscodingIndex.Value > segmentGapRequiringTranscodingChange)
- {
- _logger.LogDebug("Starting transcoding because segmentGap is {0} and max allowed gap is {1}. requestedIndex={2}", segmentId - currentTranscodingIndex.Value, segmentGapRequiringTranscodingChange, segmentId);
- startTranscoding = true;
- }
+ _logger.LogDebug("Starting transcoding because currentTranscodingIndex=null");
+ startTranscoding = true;
+ }
+ else if (segmentId < currentTranscodingIndex.Value)
+ {
+ _logger.LogDebug("Starting transcoding because requestedIndex={0} and currentTranscodingIndex={1}", segmentId, currentTranscodingIndex);
+ startTranscoding = true;
+ }
+ else if (segmentId - currentTranscodingIndex.Value > segmentGapRequiringTranscodingChange)
+ {
+ _logger.LogDebug("Starting transcoding because segmentGap is {0} and max allowed gap is {1}. requestedIndex={2}", segmentId - currentTranscodingIndex.Value, segmentGapRequiringTranscodingChange, segmentId);
+ startTranscoding = true;
+ }
- if (startTranscoding)
+ if (startTranscoding)
+ {
+ // If the playlist doesn't already exist, startup ffmpeg
+ try
{
- // If the playlist doesn't already exist, startup ffmpeg
- try
- {
- await _transcodingJobHelper.KillTranscodingJobs(streamingRequest.DeviceId, streamingRequest.PlaySessionId, p => false)
- .ConfigureAwait(false);
-
- if (currentTranscodingIndex.HasValue)
- {
- DeleteLastFile(playlistPath, segmentExtension, 0);
- }
+ await _transcodingJobHelper.KillTranscodingJobs(streamingRequest.DeviceId, streamingRequest.PlaySessionId, p => false)
+ .ConfigureAwait(false);
- streamingRequest.StartTimeTicks = streamingRequest.CurrentRuntimeTicks;
-
- state.WaitForPath = segmentPath;
- job = await _transcodingJobHelper.StartFfMpeg(
- state,
- playlistPath,
- GetCommandLineArguments(playlistPath, state, false, segmentId),
- Request,
- TranscodingJobType,
- cancellationTokenSource).ConfigureAwait(false);
- }
- catch
+ if (currentTranscodingIndex.HasValue)
{
- state.Dispose();
- throw;
+ DeleteLastFile(playlistPath, segmentExtension, 0);
}
- // await WaitForMinimumSegmentCount(playlistPath, 1, cancellationTokenSource.Token).ConfigureAwait(false);
+ streamingRequest.StartTimeTicks = streamingRequest.CurrentRuntimeTicks;
+
+ state.WaitForPath = segmentPath;
+ job = await _transcodingJobHelper.StartFfMpeg(
+ state,
+ playlistPath,
+ GetCommandLineArguments(playlistPath, state, false, segmentId),
+ Request,
+ TranscodingJobType,
+ cancellationTokenSource).ConfigureAwait(false);
}
- else
+ catch
{
- job = _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
- if (job?.TranscodingThrottler != null)
- {
- await job.TranscodingThrottler.UnpauseTranscoding().ConfigureAwait(false);
- }
+ state.Dispose();
+ throw;
}
+
+ // await WaitForMinimumSegmentCount(playlistPath, 1, cancellationTokenSource.Token).ConfigureAwait(false);
}
- }
- finally
- {
- if (!released)
+ else
{
- transcodingLock.Release();
+ job = _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
+ if (job?.TranscodingThrottler is not null)
+ {
+ await job.TranscodingThrottler.UnpauseTranscoding().ConfigureAwait(false);
+ }
}
}
-
- _logger.LogDebug("returning {0} [general case]", segmentPath);
- job ??= _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
- return await GetSegmentResult(state, playlistPath, segmentPath, segmentExtension, segmentId, job, cancellationToken).ConfigureAwait(false);
}
-
- private static double[] GetSegmentLengths(StreamState state)
- => GetSegmentLengthsInternal(state.RunTimeTicks ?? 0, state.SegmentLength);
-
- internal static double[] GetSegmentLengthsInternal(long runtimeTicks, int segmentlength)
+ finally
{
- var segmentLengthTicks = TimeSpan.FromSeconds(segmentlength).Ticks;
- var wholeSegments = runtimeTicks / segmentLengthTicks;
- var remainingTicks = runtimeTicks % segmentLengthTicks;
-
- var segmentsLen = wholeSegments + (remainingTicks == 0 ? 0 : 1);
- var segments = new double[segmentsLen];
- for (int i = 0; i < wholeSegments; i++)
+ if (!released)
{
- segments[i] = segmentlength;
+ transcodingLock.Release();
}
+ }
- if (remainingTicks != 0)
- {
- segments[^1] = TimeSpan.FromTicks(remainingTicks).TotalSeconds;
- }
+ _logger.LogDebug("returning {0} [general case]", segmentPath);
+ job ??= _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
+ return await GetSegmentResult(state, playlistPath, segmentPath, segmentExtension, segmentId, job, cancellationToken).ConfigureAwait(false);
+ }
- return segments;
- }
+ private static double[] GetSegmentLengths(StreamState state)
+ => GetSegmentLengthsInternal(state.RunTimeTicks ?? 0, state.SegmentLength);
+
+ internal static double[] GetSegmentLengthsInternal(long runtimeTicks, int segmentlength)
+ {
+ var segmentLengthTicks = TimeSpan.FromSeconds(segmentlength).Ticks;
+ var wholeSegments = runtimeTicks / segmentLengthTicks;
+ var remainingTicks = runtimeTicks % segmentLengthTicks;
- private string GetCommandLineArguments(string outputPath, StreamState state, bool isEventPlaylist, int startNumber)
+ var segmentsLen = wholeSegments + (remainingTicks == 0 ? 0 : 1);
+ var segments = new double[segmentsLen];
+ for (int i = 0; i < wholeSegments; i++)
{
- var videoCodec = _encodingHelper.GetVideoEncoder(state, _encodingOptions);
- var threads = EncodingHelper.GetNumberOfThreads(state, _encodingOptions, videoCodec);
+ segments[i] = segmentlength;
+ }
- if (state.BaseRequest.BreakOnNonKeyFrames)
- {
- // FIXME: this is actually a workaround, as ideally it really should be the client which decides whether non-keyframe
- // breakpoints are supported; but current implementation always uses "ffmpeg input seeking" which is liable
- // to produce a missing part of video stream before first keyframe is encountered, which may lead to
- // awkward cases like a few starting HLS segments having no video whatsoever, which breaks hls.js
- _logger.LogInformation("Current HLS implementation doesn't support non-keyframe breaks but one is requested, ignoring that request");
- state.BaseRequest.BreakOnNonKeyFrames = false;
- }
+ if (remainingTicks != 0)
+ {
+ segments[^1] = TimeSpan.FromTicks(remainingTicks).TotalSeconds;
+ }
- var mapArgs = state.IsOutputVideo ? _encodingHelper.GetMapArgs(state) : string.Empty;
+ return segments;
+ }
- var directory = Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(outputPath));
- var outputFileNameWithoutExtension = Path.GetFileNameWithoutExtension(outputPath);
- var outputPrefix = Path.Combine(directory, outputFileNameWithoutExtension);
- var outputExtension = EncodingHelper.GetSegmentFileExtension(state.Request.SegmentContainer);
- var outputTsArg = outputPrefix + "%d" + outputExtension;
+ private string GetCommandLineArguments(string outputPath, StreamState state, bool isEventPlaylist, int startNumber)
+ {
+ var videoCodec = _encodingHelper.GetVideoEncoder(state, _encodingOptions);
+ var threads = EncodingHelper.GetNumberOfThreads(state, _encodingOptions, videoCodec);
- var segmentFormat = string.Empty;
- var segmentContainer = outputExtension.TrimStart('.');
- var inputModifier = _encodingHelper.GetInputModifier(state, _encodingOptions, segmentContainer);
+ if (state.BaseRequest.BreakOnNonKeyFrames)
+ {
+ // FIXME: this is actually a workaround, as ideally it really should be the client which decides whether non-keyframe
+ // breakpoints are supported; but current implementation always uses "ffmpeg input seeking" which is liable
+ // to produce a missing part of video stream before first keyframe is encountered, which may lead to
+ // awkward cases like a few starting HLS segments having no video whatsoever, which breaks hls.js
+ _logger.LogInformation("Current HLS implementation doesn't support non-keyframe breaks but one is requested, ignoring that request");
+ state.BaseRequest.BreakOnNonKeyFrames = false;
+ }
- if (string.Equals(segmentContainer, "ts", StringComparison.OrdinalIgnoreCase))
- {
- segmentFormat = "mpegts";
- }
- else if (string.Equals(segmentContainer, "mp4", StringComparison.OrdinalIgnoreCase))
- {
- var outputFmp4HeaderArg = OperatingSystem.IsWindows() switch
- {
- // on Windows, the path of fmp4 header file needs to be configured
- true => " -hls_fmp4_init_filename \"" + outputPrefix + "-1" + outputExtension + "\"",
- // on Linux/Unix, ffmpeg generate fmp4 header file to m3u8 output folder
- false => " -hls_fmp4_init_filename \"" + outputFileNameWithoutExtension + "-1" + outputExtension + "\""
- };
+ var mapArgs = state.IsOutputVideo ? _encodingHelper.GetMapArgs(state) : string.Empty;
- segmentFormat = "fmp4" + outputFmp4HeaderArg;
- }
- else
- {
- _logger.LogError("Invalid HLS segment container: {SegmentContainer}, default to mpegts", segmentContainer);
- segmentFormat = "mpegts";
- }
+ var directory = Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(outputPath));
+ var outputFileNameWithoutExtension = Path.GetFileNameWithoutExtension(outputPath);
+ var outputPrefix = Path.Combine(directory, outputFileNameWithoutExtension);
+ var outputExtension = EncodingHelper.GetSegmentFileExtension(state.Request.SegmentContainer);
+ var outputTsArg = outputPrefix + "%d" + outputExtension;
- var maxMuxingQueueSize = _encodingOptions.MaxMuxingQueueSize > 128
- ? _encodingOptions.MaxMuxingQueueSize.ToString(CultureInfo.InvariantCulture)
- : "128";
+ var segmentFormat = string.Empty;
+ var segmentContainer = outputExtension.TrimStart('.');
+ var inputModifier = _encodingHelper.GetInputModifier(state, _encodingOptions, segmentContainer);
- var baseUrlParam = string.Empty;
- if (isEventPlaylist)
+ if (string.Equals(segmentContainer, "ts", StringComparison.OrdinalIgnoreCase))
+ {
+ segmentFormat = "mpegts";
+ }
+ else if (string.Equals(segmentContainer, "mp4", StringComparison.OrdinalIgnoreCase))
+ {
+ var outputFmp4HeaderArg = OperatingSystem.IsWindows() switch
{
- baseUrlParam = string.Format(
- CultureInfo.InvariantCulture,
- " -hls_base_url \"hls/{0}/\"",
- Path.GetFileNameWithoutExtension(outputPath));
- }
+ // on Windows, the path of fmp4 header file needs to be configured
+ true => " -hls_fmp4_init_filename \"" + outputPrefix + "-1" + outputExtension + "\"",
+ // on Linux/Unix, ffmpeg generate fmp4 header file to m3u8 output folder
+ false => " -hls_fmp4_init_filename \"" + outputFileNameWithoutExtension + "-1" + outputExtension + "\""
+ };
- var hlsArguments = GetHlsArguments(isEventPlaylist, state.SegmentLength);
-
- return string.Format(
- CultureInfo.InvariantCulture,
- "{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -copyts -avoid_negative_ts disabled -max_muxing_queue_size {6} -f hls -max_delay 5000000 -hls_time {7} -hls_segment_type {8} -start_number {9}{10} -hls_segment_filename \"{11}\" {12} -y \"{13}\"",
- inputModifier,
- _encodingHelper.GetInputArgument(state, _encodingOptions, segmentContainer),
- threads,
- mapArgs,
- GetVideoArguments(state, startNumber, isEventPlaylist),
- GetAudioArguments(state),
- maxMuxingQueueSize,
- state.SegmentLength.ToString(CultureInfo.InvariantCulture),
- segmentFormat,
- startNumber.ToString(CultureInfo.InvariantCulture),
- baseUrlParam,
- outputTsArg,
- hlsArguments,
- outputPath).Trim();
+ segmentFormat = "fmp4" + outputFmp4HeaderArg;
}
-
- /// <summary>
- /// Gets the HLS arguments for transcoding.
- /// </summary>
- /// <returns>The command line arguments for HLS transcoding.</returns>
- private string GetHlsArguments(bool isEventPlaylist, int segmentLength)
+ else
{
- var enableThrottling = _encodingOptions.EnableThrottling;
- var enableSegmentDeletion = _encodingOptions.EnableSegmentDeletion;
+ _logger.LogError("Invalid HLS segment container: {SegmentContainer}, default to mpegts", segmentContainer);
+ segmentFormat = "mpegts";
+ }
- // Only enable segment deletion when throttling is enabled
- if (enableThrottling && enableSegmentDeletion)
- {
- // Store enough segments for configured seconds of playback; this needs to be above throttling settings
- var segmentCount = _encodingOptions.SegmentKeepSeconds / segmentLength;
+ var maxMuxingQueueSize = _encodingOptions.MaxMuxingQueueSize > 128
+ ? _encodingOptions.MaxMuxingQueueSize.ToString(CultureInfo.InvariantCulture)
+ : "128";
+
- var baseUrlParam = string.Empty;
- if (isEventPlaylist)
- {
- baseUrlParam = string.Format(
- CultureInfo.InvariantCulture,
- " -hls_base_url \"hls/{0}/\"",
- Path.GetFileNameWithoutExtension(outputPath));
- }
++ var hlsArguments = GetHlsArguments(isEventPlaylist, state.SegmentLength);
+
+ return string.Format(
+ CultureInfo.InvariantCulture,
- "{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -copyts -avoid_negative_ts disabled -max_muxing_queue_size {6} -f hls -max_delay 5000000 -hls_time {7} -hls_segment_type {8} -start_number {9}{10} -hls_segment_filename \"{12}\" -hls_playlist_type {11} -hls_list_size 0 -y \"{13}\"",
++ "{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -copyts -avoid_negative_ts disabled -max_muxing_queue_size {6} -f hls -max_delay 5000000 -hls_time {7} -hls_segment_type {8} -start_number {9}{10} -hls_segment_filename \"{11}\" {12} -y \"{13}\"",
+ inputModifier,
+ _encodingHelper.GetInputArgument(state, _encodingOptions, segmentContainer),
+ threads,
+ mapArgs,
+ GetVideoArguments(state, startNumber, isEventPlaylist),
+ GetAudioArguments(state),
+ maxMuxingQueueSize,
+ state.SegmentLength.ToString(CultureInfo.InvariantCulture),
+ segmentFormat,
+ startNumber.ToString(CultureInfo.InvariantCulture),
+ baseUrlParam,
- isEventPlaylist ? "event" : "vod",
+ EncodingUtils.NormalizePath(outputTsArg),
++ hlsArguments,
+ EncodingUtils.NormalizePath(outputPath)).Trim();
+ }
- _logger.LogDebug("Using throttling and segment deletion, keeping {0} segments", segmentCount);
++ /// <summary>
++ /// Gets the HLS arguments for transcoding.
++ /// </summary>
++ /// <returns>The command line arguments for HLS transcoding.</returns>
++ private string GetHlsArguments(bool isEventPlaylist, int segmentLength)
++ {
++ var enableThrottling = _encodingOptions.EnableThrottling;
++ var enableSegmentDeletion = _encodingOptions.EnableSegmentDeletion;
+
- return string.Format(CultureInfo.InvariantCulture, "-hls_list_size {0} -hls_flags delete_segments", segmentCount.ToString(CultureInfo.InvariantCulture));
- }
- else
- {
- _logger.LogDebug("Using normal playback, is event playlist? {0}", isEventPlaylist);
++ // Only enable segment deletion when throttling is enabled
++ if (enableThrottling && enableSegmentDeletion)
++ {
++ // Store enough segments for configured seconds of playback; this needs to be above throttling settings
++ var segmentCount = _encodingOptions.SegmentKeepSeconds / segmentLength;
+
- return string.Format(CultureInfo.InvariantCulture, "-hls_playlist_type {0} -hls_list_size 0", isEventPlaylist ? "event" : "vod");
- }
++ _logger.LogDebug("Using throttling and segment deletion, keeping {0} segments", segmentCount);
++
++ return string.Format(CultureInfo.InvariantCulture, "-hls_list_size {0} -hls_flags delete_segments", segmentCount.ToString(CultureInfo.InvariantCulture));
++ }
++ else
++ {
++ _logger.LogDebug("Using normal playback, is event playlist? {0}", isEventPlaylist);
++
++ return string.Format(CultureInfo.InvariantCulture, "-hls_playlist_type {0} -hls_list_size 0", isEventPlaylist ? "event" : "vod");
+ }
++ }
+
- /// <summary>
- /// Gets the audio arguments for transcoding.
- /// </summary>
- /// <param name="state">The <see cref="StreamState"/>.</param>
- /// <returns>The command line arguments for audio transcoding.</returns>
- private string GetAudioArguments(StreamState state)
+ /// <summary>
+ /// Gets the audio arguments for transcoding.
+ /// </summary>
+ /// <param name="state">The <see cref="StreamState"/>.</param>
+ /// <returns>The command line arguments for audio transcoding.</returns>
+ private string GetAudioArguments(StreamState state)
+ {
+ if (state.AudioStream is null)
{
- if (state.AudioStream == null)
- {
- return string.Empty;
- }
+ return string.Empty;
+ }
- var audioCodec = _encodingHelper.GetAudioEncoder(state);
+ var audioCodec = _encodingHelper.GetAudioEncoder(state);
- if (!state.IsOutputVideo)
+ if (!state.IsOutputVideo)
+ {
+ if (EncodingHelper.IsCopyCodec(audioCodec))
{
- if (EncodingHelper.IsCopyCodec(audioCodec))
- {
- var bitStreamArgs = EncodingHelper.GetAudioBitStreamArguments(state, state.Request.SegmentContainer, state.MediaSource.Container);
+ var bitStreamArgs = EncodingHelper.GetAudioBitStreamArguments(state, state.Request.SegmentContainer, state.MediaSource.Container);
- return "-acodec copy -strict -2" + bitStreamArgs;
- }
+ return "-acodec copy -strict -2" + bitStreamArgs;
+ }
- var audioTranscodeParams = string.Empty;
+ var audioTranscodeParams = string.Empty;
- audioTranscodeParams += "-acodec " + audioCodec;
+ audioTranscodeParams += "-acodec " + audioCodec;
- if (state.OutputAudioBitrate.HasValue)
- {
- audioTranscodeParams += " -ab " + state.OutputAudioBitrate.Value.ToString(CultureInfo.InvariantCulture);
- }
+ var audioBitrate = state.OutputAudioBitrate;
+ var audioChannels = state.OutputAudioChannels;
- if (state.OutputAudioChannels.HasValue)
+ if (audioBitrate.HasValue && !EncodingHelper.LosslessAudioCodecs.Contains(state.ActualOutputAudioCodec, StringComparison.OrdinalIgnoreCase))
+ {
+ var vbrParam = _encodingHelper.GetAudioVbrModeParam(audioCodec, audioBitrate.Value / (audioChannels ?? 2));
+ if (_encodingOptions.EnableAudioVbr && vbrParam is not null)
{
- audioTranscodeParams += " -ac " + state.OutputAudioChannels.Value.ToString(CultureInfo.InvariantCulture);
+ audioTranscodeParams += vbrParam;
}
-
- if (state.OutputAudioSampleRate.HasValue)
+ else
{
- audioTranscodeParams += " -ar " + state.OutputAudioSampleRate.Value.ToString(CultureInfo.InvariantCulture);
+ audioTranscodeParams += " -ab " + audioBitrate.Value.ToString(CultureInfo.InvariantCulture);
}
-
- audioTranscodeParams += " -vn";
- return audioTranscodeParams;
}
- // flac and opus are experimental in mp4 muxer
- var strictArgs = string.Empty;
-
- if (string.Equals(state.ActualOutputAudioCodec, "flac", StringComparison.OrdinalIgnoreCase)
- || string.Equals(state.ActualOutputAudioCodec, "opus", StringComparison.OrdinalIgnoreCase))
+ if (audioChannels.HasValue)
{
- strictArgs = " -strict -2";
+ audioTranscodeParams += " -ac " + audioChannels.Value.ToString(CultureInfo.InvariantCulture);
}
- if (EncodingHelper.IsCopyCodec(audioCodec))
+ if (state.OutputAudioSampleRate.HasValue)
{
- var videoCodec = _encodingHelper.GetVideoEncoder(state, _encodingOptions);
- var bitStreamArgs = EncodingHelper.GetAudioBitStreamArguments(state, state.Request.SegmentContainer, state.MediaSource.Container);
- var copyArgs = "-codec:a:0 copy" + bitStreamArgs + strictArgs;
-
- if (EncodingHelper.IsCopyCodec(videoCodec) && state.EnableBreakOnNonKeyFrames(videoCodec))
- {
- return copyArgs + " -copypriorss:a:0 0";
- }
-
- return copyArgs;
+ audioTranscodeParams += " -ar " + state.OutputAudioSampleRate.Value.ToString(CultureInfo.InvariantCulture);
}
- var args = "-codec:a:0 " + audioCodec + strictArgs;
+ audioTranscodeParams += " -vn";
+ return audioTranscodeParams;
+ }
- var channels = state.OutputAudioChannels;
+ // dts, flac, opus and truehd are experimental in mp4 muxer
+ var strictArgs = string.Empty;
+ var actualOutputAudioCodec = state.ActualOutputAudioCodec;
+ if (string.Equals(actualOutputAudioCodec, "flac", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(actualOutputAudioCodec, "opus", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(actualOutputAudioCodec, "dts", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(actualOutputAudioCodec, "truehd", StringComparison.OrdinalIgnoreCase))
+ {
+ strictArgs = " -strict -2";
+ }
- if (channels.HasValue)
+ if (EncodingHelper.IsCopyCodec(audioCodec))
+ {
+ var videoCodec = _encodingHelper.GetVideoEncoder(state, _encodingOptions);
+ var bitStreamArgs = EncodingHelper.GetAudioBitStreamArguments(state, state.Request.SegmentContainer, state.MediaSource.Container);
+ var copyArgs = "-codec:a:0 copy" + bitStreamArgs + strictArgs;
+
+ if (EncodingHelper.IsCopyCodec(videoCodec) && state.EnableBreakOnNonKeyFrames(videoCodec))
{
- args += " -ac " + channels.Value;
+ return copyArgs + " -copypriorss:a:0 0";
}
- var bitrate = state.OutputAudioBitrate;
+ return copyArgs;
+ }
+
+ var args = "-codec:a:0 " + audioCodec + strictArgs;
+
+ var channels = state.OutputAudioChannels;
- if (bitrate.HasValue)
+ if (channels.HasValue
+ && (channels.Value != 2
+ || (state.AudioStream is not null
+ && state.AudioStream.Channels.HasValue
+ && state.AudioStream.Channels.Value > 5
+ && _encodingOptions.DownMixStereoAlgorithm == DownMixStereoAlgorithms.None)))
+ {
+ args += " -ac " + channels.Value;
+ }
+
+ var bitrate = state.OutputAudioBitrate;
+ if (bitrate.HasValue && !EncodingHelper.LosslessAudioCodecs.Contains(actualOutputAudioCodec, StringComparison.OrdinalIgnoreCase))
+ {
+ var vbrParam = _encodingHelper.GetAudioVbrModeParam(audioCodec, bitrate.Value / (channels ?? 2));
+ if (_encodingOptions.EnableAudioVbr && vbrParam is not null)
{
- args += " -ab " + bitrate.Value.ToString(CultureInfo.InvariantCulture);
+ args += vbrParam;
}
-
- if (state.OutputAudioSampleRate.HasValue)
+ else
{
- args += " -ar " + state.OutputAudioSampleRate.Value.ToString(CultureInfo.InvariantCulture);
+ args += " -ab " + bitrate.Value.ToString(CultureInfo.InvariantCulture);
}
+ }
+
+ if (state.OutputAudioSampleRate.HasValue)
+ {
+ args += " -ar " + state.OutputAudioSampleRate.Value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ args += _encodingHelper.GetAudioFilterParam(state, _encodingOptions);
- args += _encodingHelper.GetAudioFilterParam(state, _encodingOptions);
+ return args;
+ }
- return args;
+ /// <summary>
+ /// Gets the video arguments for transcoding.
+ /// </summary>
+ /// <param name="state">The <see cref="StreamState"/>.</param>
+ /// <param name="startNumber">The first number in the hls sequence.</param>
+ /// <param name="isEventPlaylist">Whether the playlist is EVENT or VOD.</param>
+ /// <returns>The command line arguments for video transcoding.</returns>
+ private string GetVideoArguments(StreamState state, int startNumber, bool isEventPlaylist)
+ {
+ if (state.VideoStream is null)
+ {
+ return string.Empty;
+ }
+
+ if (!state.IsOutputVideo)
+ {
+ return string.Empty;
}
- /// <summary>
- /// Gets the video arguments for transcoding.
- /// </summary>
- /// <param name="state">The <see cref="StreamState"/>.</param>
- /// <param name="startNumber">The first number in the hls sequence.</param>
- /// <param name="isEventPlaylist">Whether the playlist is EVENT or VOD.</param>
- /// <returns>The command line arguments for video transcoding.</returns>
- private string GetVideoArguments(StreamState state, int startNumber, bool isEventPlaylist)
+ var codec = _encodingHelper.GetVideoEncoder(state, _encodingOptions);
+
+ var args = "-codec:v:0 " + codec;
+
+ if (string.Equals(state.ActualOutputVideoCodec, "h265", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(state.ActualOutputVideoCodec, "hevc", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase))
{
- if (state.VideoStream == null)
+ if (EncodingHelper.IsCopyCodec(codec)
+ && (string.Equals(state.VideoStream.VideoRangeType, "DOVI", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(state.VideoStream.CodecTag, "dovi", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(state.VideoStream.CodecTag, "dvh1", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(state.VideoStream.CodecTag, "dvhe", StringComparison.OrdinalIgnoreCase)))
{
- return string.Empty;
+ // Prefer dvh1 to dvhe
+ args += " -tag:v:0 dvh1 -strict -2";
}
-
- if (!state.IsOutputVideo)
+ else
{
- return string.Empty;
+ // Prefer hvc1 to hev1
+ args += " -tag:v:0 hvc1";
}
+ }
- var codec = _encodingHelper.GetVideoEncoder(state, _encodingOptions);
-
- var args = "-codec:v:0 " + codec;
+ // if (state.EnableMpegtsM2TsMode)
+ // {
+ // args += " -mpegts_m2ts_mode 1";
+ // }
- if (string.Equals(state.ActualOutputVideoCodec, "h265", StringComparison.OrdinalIgnoreCase)
- || string.Equals(state.ActualOutputVideoCodec, "hevc", StringComparison.OrdinalIgnoreCase)
- || string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase)
- || string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase))
+ // See if we can save come cpu cycles by avoiding encoding.
+ if (EncodingHelper.IsCopyCodec(codec))
+ {
+ // If h264_mp4toannexb is ever added, do not use it for live tv.
+ if (state.VideoStream is not null && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
{
- if (EncodingHelper.IsCopyCodec(codec)
- && (string.Equals(state.VideoStream.VideoRangeType, "DOVI", StringComparison.OrdinalIgnoreCase)
- || string.Equals(state.VideoStream.CodecTag, "dovi", StringComparison.OrdinalIgnoreCase)
- || string.Equals(state.VideoStream.CodecTag, "dvh1", StringComparison.OrdinalIgnoreCase)
- || string.Equals(state.VideoStream.CodecTag, "dvhe", StringComparison.OrdinalIgnoreCase)))
+ string bitStreamArgs = EncodingHelper.GetBitStreamArgs(state.VideoStream);
+ if (!string.IsNullOrEmpty(bitStreamArgs))
{
- // Prefer dvh1 to dvhe
- args += " -tag:v:0 dvh1 -strict -2";
- }
- else
- {
- // Prefer hvc1 to hev1
- args += " -tag:v:0 hvc1";
+ args += " " + bitStreamArgs;
}
}
diff --cc Jellyfin.Api/Helpers/TranscodingJobHelper.cs
index f54f9eadfe,f25a718697..cee8e0f9be
--- a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
+++ b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
@@@ -422,398 -422,397 +422,397 @@@ public class TranscodingJobHelper : IDi
}
}
- /// <summary>
- /// Report the transcoding progress to the session manager.
- /// </summary>
- /// <param name="job">The <see cref="TranscodingJobDto"/> of which the progress will be reported.</param>
- /// <param name="state">The <see cref="StreamState"/> of the current transcoding job.</param>
- /// <param name="transcodingPosition">The current transcoding position.</param>
- /// <param name="framerate">The framerate of the transcoding job.</param>
- /// <param name="percentComplete">The completion percentage of the transcode.</param>
- /// <param name="bytesTranscoded">The number of bytes transcoded.</param>
- /// <param name="bitRate">The bitrate of the transcoding job.</param>
- public void ReportTranscodingProgress(
- TranscodingJobDto job,
- StreamState state,
- TimeSpan? transcodingPosition,
- float? framerate,
- double? percentComplete,
- long? bytesTranscoded,
- int? bitRate)
- {
- var ticks = transcodingPosition?.Ticks;
-
- if (job != null)
- {
- job.Framerate = framerate;
- job.CompletionPercentage = percentComplete;
- job.TranscodingPositionTicks = ticks;
- job.BytesTranscoded = bytesTranscoded;
- job.BitRate = bitRate;
- }
+ if (exs is not null)
+ {
+ throw new AggregateException("Error deleting HLS files", exs);
+ }
+ }
- var deviceId = state.Request.DeviceId;
+ /// <summary>
+ /// Report the transcoding progress to the session manager.
+ /// </summary>
+ /// <param name="job">The <see cref="TranscodingJobDto"/> of which the progress will be reported.</param>
+ /// <param name="state">The <see cref="StreamState"/> of the current transcoding job.</param>
+ /// <param name="transcodingPosition">The current transcoding position.</param>
+ /// <param name="framerate">The framerate of the transcoding job.</param>
+ /// <param name="percentComplete">The completion percentage of the transcode.</param>
+ /// <param name="bytesTranscoded">The number of bytes transcoded.</param>
+ /// <param name="bitRate">The bitrate of the transcoding job.</param>
+ public void ReportTranscodingProgress(
+ TranscodingJobDto job,
+ StreamState state,
+ TimeSpan? transcodingPosition,
+ float? framerate,
+ double? percentComplete,
+ long? bytesTranscoded,
+ int? bitRate)
+ {
+ var ticks = transcodingPosition?.Ticks;
- if (!string.IsNullOrWhiteSpace(deviceId))
- {
- var audioCodec = state.ActualOutputAudioCodec;
- var videoCodec = state.ActualOutputVideoCodec;
- var hardwareAccelerationTypeString = _serverConfigurationManager.GetEncodingOptions().HardwareAccelerationType;
- HardwareEncodingType? hardwareAccelerationType = null;
- if (!string.IsNullOrEmpty(hardwareAccelerationTypeString)
- && Enum.TryParse<HardwareEncodingType>(hardwareAccelerationTypeString, out var parsedHardwareAccelerationType))
- {
- hardwareAccelerationType = parsedHardwareAccelerationType;
- }
+ if (job is not null)
+ {
+ job.Framerate = framerate;
+ job.CompletionPercentage = percentComplete;
+ job.TranscodingPositionTicks = ticks;
+ job.BytesTranscoded = bytesTranscoded;
+ job.BitRate = bitRate;
+ }
- _sessionManager.ReportTranscodingInfo(deviceId, new TranscodingInfo
- {
- Bitrate = bitRate ?? state.TotalOutputBitrate,
- AudioCodec = audioCodec,
- VideoCodec = videoCodec,
- Container = state.OutputContainer,
- Framerate = framerate,
- CompletionPercentage = percentComplete,
- Width = state.OutputWidth,
- Height = state.OutputHeight,
- AudioChannels = state.OutputAudioChannels,
- IsAudioDirect = EncodingHelper.IsCopyCodec(state.OutputAudioCodec),
- IsVideoDirect = EncodingHelper.IsCopyCodec(state.OutputVideoCodec),
- HardwareAccelerationType = hardwareAccelerationType,
- TranscodeReasons = state.TranscodeReasons
- });
- }
+ var deviceId = state.Request.DeviceId;
+
+ if (!string.IsNullOrWhiteSpace(deviceId))
+ {
+ var audioCodec = state.ActualOutputAudioCodec;
+ var videoCodec = state.ActualOutputVideoCodec;
+ var hardwareAccelerationTypeString = _serverConfigurationManager.GetEncodingOptions().HardwareAccelerationType;
+ HardwareEncodingType? hardwareAccelerationType = null;
+ if (Enum.TryParse<HardwareEncodingType>(hardwareAccelerationTypeString, out var parsedHardwareAccelerationType))
+ {
+ hardwareAccelerationType = parsedHardwareAccelerationType;
+ }
+
+ _sessionManager.ReportTranscodingInfo(deviceId, new TranscodingInfo
+ {
+ Bitrate = bitRate ?? state.TotalOutputBitrate,
+ AudioCodec = audioCodec,
+ VideoCodec = videoCodec,
+ Container = state.OutputContainer,
+ Framerate = framerate,
+ CompletionPercentage = percentComplete,
+ Width = state.OutputWidth,
+ Height = state.OutputHeight,
+ AudioChannels = state.OutputAudioChannels,
+ IsAudioDirect = EncodingHelper.IsCopyCodec(state.OutputAudioCodec),
+ IsVideoDirect = EncodingHelper.IsCopyCodec(state.OutputVideoCodec),
+ HardwareAccelerationType = hardwareAccelerationType,
+ TranscodeReasons = state.TranscodeReasons
+ });
}
+ }
- /// <summary>
- /// Starts FFmpeg.
- /// </summary>
- /// <param name="state">The state.</param>
- /// <param name="outputPath">The output path.</param>
- /// <param name="commandLineArguments">The command line arguments for FFmpeg.</param>
- /// <param name="request">The <see cref="HttpRequest"/>.</param>
- /// <param name="transcodingJobType">The <see cref="TranscodingJobType"/>.</param>
- /// <param name="cancellationTokenSource">The cancellation token source.</param>
- /// <param name="workingDirectory">The working directory.</param>
- /// <returns>Task.</returns>
- public async Task<TranscodingJobDto> StartFfMpeg(
- StreamState state,
- string outputPath,
- string commandLineArguments,
- HttpRequest request,
- TranscodingJobType transcodingJobType,
- CancellationTokenSource cancellationTokenSource,
- string? workingDirectory = null)
- {
- var directory = Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(outputPath));
- Directory.CreateDirectory(directory);
-
- await AcquireResources(state, cancellationTokenSource).ConfigureAwait(false);
-
- if (state.VideoRequest != null && !EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
- {
- var userId = request.HttpContext.User.GetUserId();
- var user = userId.Equals(default) ? null : _userManager.GetUserById(userId);
- if (user != null && !user.HasPermission(PermissionKind.EnableVideoPlaybackTranscoding))
- {
- this.OnTranscodeFailedToStart(outputPath, transcodingJobType, state);
+ /// <summary>
+ /// Starts FFmpeg.
+ /// </summary>
+ /// <param name="state">The state.</param>
+ /// <param name="outputPath">The output path.</param>
+ /// <param name="commandLineArguments">The command line arguments for FFmpeg.</param>
+ /// <param name="request">The <see cref="HttpRequest"/>.</param>
+ /// <param name="transcodingJobType">The <see cref="TranscodingJobType"/>.</param>
+ /// <param name="cancellationTokenSource">The cancellation token source.</param>
+ /// <param name="workingDirectory">The working directory.</param>
+ /// <returns>Task.</returns>
+ public async Task<TranscodingJobDto> StartFfMpeg(
+ StreamState state,
+ string outputPath,
+ string commandLineArguments,
+ HttpRequest request,
+ TranscodingJobType transcodingJobType,
+ CancellationTokenSource cancellationTokenSource,
+ string? workingDirectory = null)
+ {
+ var directory = Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(outputPath));
+ Directory.CreateDirectory(directory);
- throw new ArgumentException("User does not have access to video transcoding.");
- }
- }
+ await AcquireResources(state, cancellationTokenSource).ConfigureAwait(false);
- if (string.IsNullOrEmpty(_mediaEncoder.EncoderPath))
+ if (state.VideoRequest is not null && !EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
+ {
+ var userId = request.HttpContext.User.GetUserId();
+ var user = userId.Equals(default) ? null : _userManager.GetUserById(userId);
+ if (user is not null && !user.HasPermission(PermissionKind.EnableVideoPlaybackTranscoding))
{
- throw new ArgumentException("FFmpeg path not set.");
+ this.OnTranscodeFailedToStart(outputPath, transcodingJobType, state);
+
+ throw new ArgumentException("User does not have access to video transcoding.");
}
+ }
- // If subtitles get burned in fonts may need to be extracted from the media file
- if (state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode)
+ ArgumentException.ThrowIfNullOrEmpty(_mediaEncoder.EncoderPath);
+
+ // If subtitles get burned in fonts may need to be extracted from the media file
+ if (state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode)
+ {
+ var attachmentPath = Path.Combine(_appPaths.CachePath, "attachments", state.MediaSource.Id);
+ if (state.VideoType != VideoType.Dvd)
{
- var attachmentPath = Path.Combine(_appPaths.CachePath, "attachments", state.MediaSource.Id);
await _attachmentExtractor.ExtractAllAttachments(state.MediaPath, state.MediaSource, attachmentPath, cancellationTokenSource.Token).ConfigureAwait(false);
-
- if (state.SubtitleStream.IsExternal && string.Equals(Path.GetExtension(state.SubtitleStream.Path), ".mks", StringComparison.OrdinalIgnoreCase))
- {
- string subtitlePath = state.SubtitleStream.Path;
- string subtitlePathArgument = string.Format(CultureInfo.InvariantCulture, "file:\"{0}\"", subtitlePath.Replace("\"", "\\\"", StringComparison.Ordinal));
- string subtitleId = subtitlePath.GetMD5().ToString("N", CultureInfo.InvariantCulture);
-
- await _attachmentExtractor.ExtractAllAttachmentsExternal(subtitlePathArgument, subtitleId, attachmentPath, cancellationTokenSource.Token).ConfigureAwait(false);
- }
}
- var process = new Process
+ if (state.SubtitleStream.IsExternal && string.Equals(Path.GetExtension(state.SubtitleStream.Path), ".mks", StringComparison.OrdinalIgnoreCase))
{
- StartInfo = new ProcessStartInfo
- {
- WindowStyle = ProcessWindowStyle.Hidden,
- CreateNoWindow = true,
- UseShellExecute = false,
-
- // Must consume both stdout and stderr or deadlocks may occur
- // RedirectStandardOutput = true,
- RedirectStandardError = true,
- RedirectStandardInput = true,
- FileName = _mediaEncoder.EncoderPath,
- Arguments = commandLineArguments,
- WorkingDirectory = string.IsNullOrWhiteSpace(workingDirectory) ? string.Empty : workingDirectory,
- ErrorDialog = false
- },
- EnableRaisingEvents = true
- };
+ string subtitlePath = state.SubtitleStream.Path;
+ string subtitlePathArgument = string.Format(CultureInfo.InvariantCulture, "file:\"{0}\"", subtitlePath.Replace("\"", "\\\"", StringComparison.Ordinal));
+ string subtitleId = subtitlePath.GetMD5().ToString("N", CultureInfo.InvariantCulture);
- var transcodingJob = this.OnTranscodeBeginning(
- outputPath,
- state.Request.PlaySessionId,
- state.MediaSource.LiveStreamId,
- Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture),
- transcodingJobType,
- process,
- state.Request.DeviceId,
- state,
- cancellationTokenSource);
-
- _logger.LogInformation("{Filename} {Arguments}", process.StartInfo.FileName, process.StartInfo.Arguments);
-
- var logFilePrefix = "FFmpeg.Transcode-";
- if (state.VideoRequest != null
- && EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
- {
- logFilePrefix = EncodingHelper.IsCopyCodec(state.OutputAudioCodec)
- ? "FFmpeg.Remux-"
- : "FFmpeg.DirectStream-";
+ await _attachmentExtractor.ExtractAllAttachmentsExternal(subtitlePathArgument, subtitleId, attachmentPath, cancellationTokenSource.Token).ConfigureAwait(false);
}
+ }
- var logFilePath = Path.Combine(
- _serverConfigurationManager.ApplicationPaths.LogDirectoryPath,
- $"{logFilePrefix}{DateTime.Now:yyyy-MM-dd_HH-mm-ss}_{state.Request.MediaSourceId}_{Guid.NewGuid().ToString()[..8]}.log");
+ var process = new Process
+ {
+ StartInfo = new ProcessStartInfo
+ {
+ WindowStyle = ProcessWindowStyle.Hidden,
+ CreateNoWindow = true,
+ UseShellExecute = false,
+
+ // Must consume both stdout and stderr or deadlocks may occur
+ // RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ RedirectStandardInput = true,
+ FileName = _mediaEncoder.EncoderPath,
+ Arguments = commandLineArguments,
+ WorkingDirectory = string.IsNullOrWhiteSpace(workingDirectory) ? string.Empty : workingDirectory,
+ ErrorDialog = false
+ },
+ EnableRaisingEvents = true
+ };
+
+ var transcodingJob = this.OnTranscodeBeginning(
+ outputPath,
+ state.Request.PlaySessionId,
+ state.MediaSource.LiveStreamId,
+ Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture),
+ transcodingJobType,
+ process,
+ state.Request.DeviceId,
+ state,
+ cancellationTokenSource);
+
+ _logger.LogInformation("{Filename} {Arguments}", process.StartInfo.FileName, process.StartInfo.Arguments);
+
+ var logFilePrefix = "FFmpeg.Transcode-";
+ if (state.VideoRequest is not null
+ && EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
+ {
+ logFilePrefix = EncodingHelper.IsCopyCodec(state.OutputAudioCodec)
+ ? "FFmpeg.Remux-"
+ : "FFmpeg.DirectStream-";
+ }
- // FFmpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
- Stream logStream = new FileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
+ var logFilePath = Path.Combine(
+ _serverConfigurationManager.ApplicationPaths.LogDirectoryPath,
+ $"{logFilePrefix}{DateTime.Now:yyyy-MM-dd_HH-mm-ss}_{state.Request.MediaSourceId}_{Guid.NewGuid().ToString()[..8]}.log");
- var commandLineLogMessage = process.StartInfo.FileName + " " + process.StartInfo.Arguments;
- var commandLineLogMessageBytes = Encoding.UTF8.GetBytes(request.Path + Environment.NewLine + Environment.NewLine + JsonSerializer.Serialize(state.MediaSource) + Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine);
- await logStream.WriteAsync(commandLineLogMessageBytes, cancellationTokenSource.Token).ConfigureAwait(false);
+ // FFmpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
+ Stream logStream = new FileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
- process.Exited += (sender, args) => OnFfMpegProcessExited(process, transcodingJob, state);
+ var commandLineLogMessage = process.StartInfo.FileName + " " + process.StartInfo.Arguments;
+ var commandLineLogMessageBytes = Encoding.UTF8.GetBytes(request.Path + Environment.NewLine + Environment.NewLine + JsonSerializer.Serialize(state.MediaSource) + Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine);
+ await logStream.WriteAsync(commandLineLogMessageBytes, cancellationTokenSource.Token).ConfigureAwait(false);
- try
- {
- process.Start();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error starting FFmpeg");
+ process.Exited += (sender, args) => OnFfMpegProcessExited(process, transcodingJob, state);
- this.OnTranscodeFailedToStart(outputPath, transcodingJobType, state);
+ try
+ {
+ process.Start();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error starting FFmpeg");
- throw;
- }
+ this.OnTranscodeFailedToStart(outputPath, transcodingJobType, state);
- _logger.LogDebug("Launched FFmpeg process");
- state.TranscodingJob = transcodingJob;
+ throw;
+ }
- // Important - don't await the log task or we won't be able to kill FFmpeg when the user stops playback
- _ = new JobLogger(_logger).StartStreamingLog(state, process.StandardError.BaseStream, logStream);
+ _logger.LogDebug("Launched FFmpeg process");
+ state.TranscodingJob = transcodingJob;
- // Wait for the file to exist before proceeding
- var ffmpegTargetFile = state.WaitForPath ?? outputPath;
- _logger.LogDebug("Waiting for the creation of {0}", ffmpegTargetFile);
- while (!File.Exists(ffmpegTargetFile) && !transcodingJob.HasExited)
- {
- await Task.Delay(100, cancellationTokenSource.Token).ConfigureAwait(false);
- }
+ // Important - don't await the log task or we won't be able to kill FFmpeg when the user stops playback
+ _ = new JobLogger(_logger).StartStreamingLog(state, process.StandardError.BaseStream, logStream);
- _logger.LogDebug("File {0} created or transcoding has finished", ffmpegTargetFile);
+ // Wait for the file to exist before proceeding
+ var ffmpegTargetFile = state.WaitForPath ?? outputPath;
+ _logger.LogDebug("Waiting for the creation of {0}", ffmpegTargetFile);
+ while (!File.Exists(ffmpegTargetFile) && !transcodingJob.HasExited)
+ {
+ await Task.Delay(100, cancellationTokenSource.Token).ConfigureAwait(false);
+ }
- if (state.IsInputVideo && transcodingJob.Type == TranscodingJobType.Progressive && !transcodingJob.HasExited)
- {
- await Task.Delay(1000, cancellationTokenSource.Token).ConfigureAwait(false);
+ _logger.LogDebug("File {0} created or transcoding has finished", ffmpegTargetFile);
- if (state.ReadInputAtNativeFramerate && !transcodingJob.HasExited)
- {
- await Task.Delay(1500, cancellationTokenSource.Token).ConfigureAwait(false);
- }
- }
+ if (state.IsInputVideo && transcodingJob.Type == TranscodingJobType.Progressive && !transcodingJob.HasExited)
+ {
+ await Task.Delay(1000, cancellationTokenSource.Token).ConfigureAwait(false);
- if (!transcodingJob.HasExited)
+ if (state.ReadInputAtNativeFramerate && !transcodingJob.HasExited)
{
- StartThrottler(state, transcodingJob);
+ await Task.Delay(1500, cancellationTokenSource.Token).ConfigureAwait(false);
}
- else if (transcodingJob.ExitCode != 0)
- {
- throw new FfmpegException(string.Format(CultureInfo.InvariantCulture, "FFmpeg exited with code {0}", transcodingJob.ExitCode));
- }
-
- _logger.LogDebug("StartFfMpeg() finished successfully");
+ }
- return transcodingJob;
+ if (!transcodingJob.HasExited)
+ {
+ StartThrottler(state, transcodingJob);
}
+ else if (transcodingJob.ExitCode != 0)
+ {
+ throw new FfmpegException(string.Format(CultureInfo.InvariantCulture, "FFmpeg exited with code {0}", transcodingJob.ExitCode));
+ }
+
+ _logger.LogDebug("StartFfMpeg() finished successfully");
- private void StartThrottler(StreamState state, TranscodingJobDto transcodingJob)
+ return transcodingJob;
+ }
+
+ private void StartThrottler(StreamState state, TranscodingJobDto transcodingJob)
+ {
+ if (EnableThrottling(state))
{
- if (EnableThrottling(state))
- {
- transcodingJob.TranscodingThrottler = new TranscodingThrottler(transcodingJob, _loggerFactory.CreateLogger<TranscodingThrottler>(), _serverConfigurationManager, _fileSystem, _mediaEncoder);
- transcodingJob.TranscodingThrottler.Start();
- }
- transcodingJob.TranscodingThrottler = new TranscodingThrottler(transcodingJob, new Logger<TranscodingThrottler>(new LoggerFactory()), _serverConfigurationManager, _fileSystem, _mediaEncoder);
++ transcodingJob.TranscodingThrottler = new TranscodingThrottler(transcodingJob, _loggerFactory.CreateLogger<TranscodingThrottler>(), _serverConfigurationManager, _fileSystem, _mediaEncoder);
+ transcodingJob.TranscodingThrottler.Start();
}
+ }
+
+ private bool EnableThrottling(StreamState state)
+ {
+ var encodingOptions = _serverConfigurationManager.GetEncodingOptions();
- private bool EnableThrottling(StreamState state)
+ return state.InputProtocol == MediaProtocol.File &&
+ state.RunTimeTicks.HasValue &&
+ state.RunTimeTicks.Value >= TimeSpan.FromMinutes(5).Ticks &&
+ state.IsInputVideo &&
+ state.VideoType == VideoType.VideoFile;
+ }
+
+ /// <summary>
+ /// Called when [transcode beginning].
+ /// </summary>
+ /// <param name="path">The path.</param>
+ /// <param name="playSessionId">The play session identifier.</param>
+ /// <param name="liveStreamId">The live stream identifier.</param>
+ /// <param name="transcodingJobId">The transcoding job identifier.</param>
+ /// <param name="type">The type.</param>
+ /// <param name="process">The process.</param>
+ /// <param name="deviceId">The device id.</param>
+ /// <param name="state">The state.</param>
+ /// <param name="cancellationTokenSource">The cancellation token source.</param>
+ /// <returns>TranscodingJob.</returns>
+ public TranscodingJobDto OnTranscodeBeginning(
+ string path,
+ string? playSessionId,
+ string? liveStreamId,
+ string transcodingJobId,
+ TranscodingJobType type,
+ Process process,
+ string? deviceId,
+ StreamState state,
+ CancellationTokenSource cancellationTokenSource)
+ {
+ lock (_activeTranscodingJobs)
{
- var encodingOptions = _serverConfigurationManager.GetEncodingOptions();
+ var job = new TranscodingJobDto(_loggerFactory.CreateLogger<TranscodingJobDto>())
+ {
+ Type = type,
+ Path = path,
+ Process = process,
+ ActiveRequestCount = 1,
+ DeviceId = deviceId,
+ CancellationTokenSource = cancellationTokenSource,
+ Id = transcodingJobId,
+ PlaySessionId = playSessionId,
+ LiveStreamId = liveStreamId,
+ MediaSource = state.MediaSource
+ };
- return state.InputProtocol == MediaProtocol.File &&
- state.RunTimeTicks.HasValue &&
- state.RunTimeTicks.Value >= TimeSpan.FromMinutes(5).Ticks &&
- state.IsInputVideo &&
- state.VideoType == VideoType.VideoFile;
- }
-
- /// <summary>
- /// Called when [transcode beginning].
- /// </summary>
- /// <param name="path">The path.</param>
- /// <param name="playSessionId">The play session identifier.</param>
- /// <param name="liveStreamId">The live stream identifier.</param>
- /// <param name="transcodingJobId">The transcoding job identifier.</param>
- /// <param name="type">The type.</param>
- /// <param name="process">The process.</param>
- /// <param name="deviceId">The device id.</param>
- /// <param name="state">The state.</param>
- /// <param name="cancellationTokenSource">The cancellation token source.</param>
- /// <returns>TranscodingJob.</returns>
- public TranscodingJobDto OnTranscodeBeginning(
- string path,
- string? playSessionId,
- string? liveStreamId,
- string transcodingJobId,
- TranscodingJobType type,
- Process process,
- string? deviceId,
- StreamState state,
- CancellationTokenSource cancellationTokenSource)
- {
- lock (_activeTranscodingJobs)
- {
- var job = new TranscodingJobDto(_loggerFactory.CreateLogger<TranscodingJobDto>())
- {
- Type = type,
- Path = path,
- Process = process,
- ActiveRequestCount = 1,
- DeviceId = deviceId,
- CancellationTokenSource = cancellationTokenSource,
- Id = transcodingJobId,
- PlaySessionId = playSessionId,
- LiveStreamId = liveStreamId,
- MediaSource = state.MediaSource
- };
-
- _activeTranscodingJobs.Add(job);
-
- ReportTranscodingProgress(job, state, null, null, null, null, null);
-
- return job;
- }
+ _activeTranscodingJobs.Add(job);
+
+ ReportTranscodingProgress(job, state, null, null, null, null, null);
+
+ return job;
}
+ }
- /// <summary>
- /// Called when [transcode end].
- /// </summary>
- /// <param name="job">The transcode job.</param>
- public void OnTranscodeEndRequest(TranscodingJobDto job)
+ /// <summary>
+ /// Called when [transcode end].
+ /// </summary>
+ /// <param name="job">The transcode job.</param>
+ public void OnTranscodeEndRequest(TranscodingJobDto job)
+ {
+ job.ActiveRequestCount--;
+ _logger.LogDebug("OnTranscodeEndRequest job.ActiveRequestCount={ActiveRequestCount}", job.ActiveRequestCount);
+ if (job.ActiveRequestCount <= 0)
{
- job.ActiveRequestCount--;
- _logger.LogDebug("OnTranscodeEndRequest job.ActiveRequestCount={ActiveRequestCount}", job.ActiveRequestCount);
- if (job.ActiveRequestCount <= 0)
- {
- PingTimer(job, false);
- }
+ PingTimer(job, false);
}
+ }
- /// <summary>
- /// <summary>
- /// The progressive
- /// </summary>
- /// Called when [transcode failed to start].
- /// </summary>
- /// <param name="path">The path.</param>
- /// <param name="type">The type.</param>
- /// <param name="state">The state.</param>
- public void OnTranscodeFailedToStart(string path, TranscodingJobType type, StreamState state)
+ /// <summary>
+ /// <summary>
+ /// The progressive
+ /// </summary>
+ /// Called when [transcode failed to start].
+ /// </summary>
+ /// <param name="path">The path.</param>
+ /// <param name="type">The type.</param>
+ /// <param name="state">The state.</param>
+ public void OnTranscodeFailedToStart(string path, TranscodingJobType type, StreamState state)
+ {
+ lock (_activeTranscodingJobs)
{
- lock (_activeTranscodingJobs)
- {
- var job = _activeTranscodingJobs.FirstOrDefault(j => j.Type == type && string.Equals(j.Path, path, StringComparison.OrdinalIgnoreCase));
+ var job = _activeTranscodingJobs.FirstOrDefault(j => j.Type == type && string.Equals(j.Path, path, StringComparison.OrdinalIgnoreCase));
- if (job != null)
- {
- _activeTranscodingJobs.Remove(job);
- }
- }
-
- lock (_transcodingLocks)
+ if (job is not null)
{
- _transcodingLocks.Remove(path);
+ _activeTranscodingJobs.Remove(job);
}
+ }
- if (!string.IsNullOrWhiteSpace(state.Request.DeviceId))
- {
- _sessionManager.ClearTranscodingInfo(state.Request.DeviceId);
- }
+ lock (_transcodingLocks)
+ {
+ _transcodingLocks.Remove(path);
}
- /// <summary>
- /// Processes the exited.
- /// </summary>
- /// <param name="process">The process.</param>
- /// <param name="job">The job.</param>
- /// <param name="state">The state.</param>
- private void OnFfMpegProcessExited(Process process, TranscodingJobDto job, StreamState state)
+ if (!string.IsNullOrWhiteSpace(state.Request.DeviceId))
{
- job.HasExited = true;
- job.ExitCode = process.ExitCode;
+ _sessionManager.ClearTranscodingInfo(state.Request.DeviceId);
+ }
+ }
- ReportTranscodingProgress(job, state, null, null, null, null, null);
+ /// <summary>
+ /// Processes the exited.
+ /// </summary>
+ /// <param name="process">The process.</param>
+ /// <param name="job">The job.</param>
+ /// <param name="state">The state.</param>
+ private void OnFfMpegProcessExited(Process process, TranscodingJobDto job, StreamState state)
+ {
+ job.HasExited = true;
+ job.ExitCode = process.ExitCode;
- _logger.LogDebug("Disposing stream resources");
- state.Dispose();
+ ReportTranscodingProgress(job, state, null, null, null, null, null);
- if (process.ExitCode == 0)
- {
- _logger.LogInformation("FFmpeg exited with code 0");
- }
- else
- {
- _logger.LogError("FFmpeg exited with code {0}", process.ExitCode);
- }
+ _logger.LogDebug("Disposing stream resources");
+ state.Dispose();
- job.Dispose();
+ if (process.ExitCode == 0)
+ {
+ _logger.LogInformation("FFmpeg exited with code 0");
}
-
- private async Task AcquireResources(StreamState state, CancellationTokenSource cancellationTokenSource)
+ else
{
- if (state.MediaSource.RequiresOpening && string.IsNullOrWhiteSpace(state.Request.LiveStreamId))
- {
- var liveStreamResponse = await _mediaSourceManager.OpenLiveStream(
- new LiveStreamRequest { OpenToken = state.MediaSource.OpenToken },
- cancellationTokenSource.Token)
- .ConfigureAwait(false);
- var encodingOptions = _serverConfigurationManager.GetEncodingOptions();
+ _logger.LogError("FFmpeg exited with code {0}", process.ExitCode);
+ }
- _encodingHelper.AttachMediaSourceInfo(state, encodingOptions, liveStreamResponse.MediaSource, state.RequestedUrl);
+ job.Dispose();
+ }
- if (state.VideoRequest != null)
- {
- _encodingHelper.TryStreamCopy(state);
- }
- }
+ private async Task AcquireResources(StreamState state, CancellationTokenSource cancellationTokenSource)
+ {
+ if (state.MediaSource.RequiresOpening && string.IsNullOrWhiteSpace(state.Request.LiveStreamId))
+ {
+ var liveStreamResponse = await _mediaSourceManager.OpenLiveStream(
+ new LiveStreamRequest { OpenToken = state.MediaSource.OpenToken },
+ cancellationTokenSource.Token)
+ .ConfigureAwait(false);
+ var encodingOptions = _serverConfigurationManager.GetEncodingOptions();
+
+ _encodingHelper.AttachMediaSourceInfo(state, encodingOptions, liveStreamResponse.MediaSource, state.RequestedUrl);
- if (state.MediaSource.BufferMs.HasValue)
+ if (state.VideoRequest is not null)
{
- await Task.Delay(state.MediaSource.BufferMs.Value, cancellationTokenSource.Token).ConfigureAwait(false);
+ _encodingHelper.TryStreamCopy(state);
}
}
diff --cc MediaBrowser.Model/Configuration/EncodingOptions.cs
index 0080506020,ac2f1e71a3..b5b6e86c8c
--- a/MediaBrowser.Model/Configuration/EncodingOptions.cs
+++ b/MediaBrowser.Model/Configuration/EncodingOptions.cs
@@@ -1,134 -1,254 +1,266 @@@
#nullable disable
- #pragma warning disable CS1591
+ using MediaBrowser.Model.Entities;
- namespace MediaBrowser.Model.Configuration
+ namespace MediaBrowser.Model.Configuration;
+
+ /// <summary>
+ /// Class EncodingOptions.
+ /// </summary>
+ public class EncodingOptions
{
- public class EncodingOptions
+ /// <summary>
+ /// Initializes a new instance of the <see cref="EncodingOptions" /> class.
+ /// </summary>
+ public EncodingOptions()
{
- public EncodingOptions()
- {
- EnableFallbackFont = false;
- DownMixAudioBoost = 2;
- MaxMuxingQueueSize = 2048;
- EnableThrottling = false;
- EnableSegmentDeletion = false;
- ThrottleDelaySeconds = 180;
- SegmentKeepSeconds = 360;
- EncodingThreadCount = -1;
- // This is a DRM device that is almost guaranteed to be there on every intel platform,
- // plus it's the default one in ffmpeg if you don't specify anything
- VaapiDevice = "/dev/dri/renderD128";
- EnableTonemapping = false;
- EnableVppTonemapping = false;
- TonemappingAlgorithm = "bt2390";
- TonemappingRange = "auto";
- TonemappingDesat = 0;
- TonemappingThreshold = 0.8;
- TonemappingPeak = 100;
- TonemappingParam = 0;
- VppTonemappingBrightness = 0;
- VppTonemappingContrast = 1.2;
- H264Crf = 23;
- H265Crf = 28;
- DeinterlaceDoubleRate = false;
- DeinterlaceMethod = "yadif";
- EnableDecodingColorDepth10Hevc = true;
- EnableDecodingColorDepth10Vp9 = true;
- EnableEnhancedNvdecDecoder = false;
- PreferSystemNativeHwDecoder = true;
- EnableIntelLowPowerH264HwEncoder = false;
- EnableIntelLowPowerHevcHwEncoder = false;
- EnableHardwareEncoding = true;
- AllowHevcEncoding = false;
- EnableSubtitleExtraction = true;
- AllowOnDemandMetadataBasedKeyframeExtractionForExtensions = new[] { "mkv" };
- HardwareDecodingCodecs = new string[] { "h264", "vc1" };
- }
-
- public int EncodingThreadCount { get; set; }
-
- public string TranscodingTempPath { get; set; }
-
- public string FallbackFontPath { get; set; }
-
- public bool EnableFallbackFont { get; set; }
-
- public double DownMixAudioBoost { get; set; }
-
- public int MaxMuxingQueueSize { get; set; }
-
- public bool EnableThrottling { get; set; }
-
- public bool EnableSegmentDeletion { get; set; }
-
- public int ThrottleDelaySeconds { get; set; }
-
- public int SegmentKeepSeconds { get; set; }
-
- public string HardwareAccelerationType { get; set; }
-
- /// <summary>
- /// Gets or sets the FFmpeg path as set by the user via the UI.
- /// </summary>
- public string EncoderAppPath { get; set; }
-
- /// <summary>
- /// Gets or sets the current FFmpeg path being used by the system and displayed on the transcode page.
- /// </summary>
- public string EncoderAppPathDisplay { get; set; }
-
- public string VaapiDevice { get; set; }
-
- public bool EnableTonemapping { get; set; }
-
- public bool EnableVppTonemapping { get; set; }
-
- public string TonemappingAlgorithm { get; set; }
-
- public string TonemappingRange { get; set; }
-
- public double TonemappingDesat { get; set; }
-
- public double TonemappingThreshold { get; set; }
-
- public double TonemappingPeak { get; set; }
-
- public double TonemappingParam { get; set; }
-
- public double VppTonemappingBrightness { get; set; }
-
- public double VppTonemappingContrast { get; set; }
-
- public int H264Crf { get; set; }
-
- public int H265Crf { get; set; }
-
- public string EncoderPreset { get; set; }
-
- public bool DeinterlaceDoubleRate { get; set; }
-
- public string DeinterlaceMethod { get; set; }
-
- public bool EnableDecodingColorDepth10Hevc { get; set; }
-
- public bool EnableDecodingColorDepth10Vp9 { get; set; }
-
- public bool EnableEnhancedNvdecDecoder { get; set; }
-
- public bool PreferSystemNativeHwDecoder { get; set; }
-
- public bool EnableIntelLowPowerH264HwEncoder { get; set; }
-
- public bool EnableIntelLowPowerHevcHwEncoder { get; set; }
-
- public bool EnableHardwareEncoding { get; set; }
-
- public bool AllowHevcEncoding { get; set; }
-
- public bool EnableSubtitleExtraction { get; set; }
-
- public string[] HardwareDecodingCodecs { get; set; }
-
- public string[] AllowOnDemandMetadataBasedKeyframeExtractionForExtensions { get; set; }
+ EnableFallbackFont = false;
+ EnableAudioVbr = false;
+ DownMixAudioBoost = 2;
+ DownMixStereoAlgorithm = DownMixStereoAlgorithms.None;
+ MaxMuxingQueueSize = 2048;
+ EnableThrottling = false;
+ ThrottleDelaySeconds = 180;
++ EnableSegmentDeletion = false;
++ SegmentKeepSeconds = 360;
+ EncodingThreadCount = -1;
+ // This is a DRM device that is almost guaranteed to be there on every intel platform,
+ // plus it's the default one in ffmpeg if you don't specify anything
+ VaapiDevice = "/dev/dri/renderD128";
+ EnableTonemapping = false;
+ EnableVppTonemapping = false;
+ TonemappingAlgorithm = "bt2390";
+ TonemappingMode = "auto";
+ TonemappingRange = "auto";
+ TonemappingDesat = 0;
+ TonemappingPeak = 100;
+ TonemappingParam = 0;
+ VppTonemappingBrightness = 16;
+ VppTonemappingContrast = 1;
+ H264Crf = 23;
+ H265Crf = 28;
+ DeinterlaceDoubleRate = false;
+ DeinterlaceMethod = "yadif";
+ EnableDecodingColorDepth10Hevc = true;
+ EnableDecodingColorDepth10Vp9 = true;
+ // Enhanced Nvdec or system native decoder is required for DoVi to SDR tone-mapping.
+ EnableEnhancedNvdecDecoder = true;
+ PreferSystemNativeHwDecoder = true;
+ EnableIntelLowPowerH264HwEncoder = false;
+ EnableIntelLowPowerHevcHwEncoder = false;
+ EnableHardwareEncoding = true;
+ AllowHevcEncoding = false;
+ EnableSubtitleExtraction = true;
+ AllowOnDemandMetadataBasedKeyframeExtractionForExtensions = new[] { "mkv" };
+ HardwareDecodingCodecs = new string[] { "h264", "vc1" };
}
+
+ /// <summary>
+ /// Gets or sets the thread count used for encoding.
+ /// </summary>
+ public int EncodingThreadCount { get; set; }
+
+ /// <summary>
+ /// Gets or sets the temporary transcoding path.
+ /// </summary>
+ public string TranscodingTempPath { get; set; }
+
+ /// <summary>
+ /// Gets or sets the path to the fallback font.
+ /// </summary>
+ public string FallbackFontPath { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to use the fallback font.
+ /// </summary>
+ public bool EnableFallbackFont { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether audio VBR is enabled.
+ /// </summary>
+ public bool EnableAudioVbr { get; set; }
+
+ /// <summary>
+ /// Gets or sets the audio boost applied when downmixing audio.
+ /// </summary>
+ public double DownMixAudioBoost { get; set; }
+
+ /// <summary>
+ /// Gets or sets the algorithm used for downmixing audio to stereo.
+ /// </summary>
+ public DownMixStereoAlgorithms DownMixStereoAlgorithm { get; set; }
+
+ /// <summary>
+ /// Gets or sets the maximum size of the muxing queue.
+ /// </summary>
+ public int MaxMuxingQueueSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether throttling is enabled.
+ /// </summary>
+ public bool EnableThrottling { get; set; }
+
+ /// <summary>
+ /// Gets or sets the delay after which throttling happens.
+ /// </summary>
+ public int ThrottleDelaySeconds { get; set; }
++
++ /// <summary>
++ /// Gets or sets a value indicating whether segment deletion is enabled.
++ /// </summary>
++ public bool EnableSegmentDeletion { get; set; }
++
++ /// <summary>
++ /// Gets or sets seconds for which segments should be kept before being deleted.
++ /// </summary>
++ public int SegmentKeepSeconds { get; set; }
+
+ /// <summary>
+ /// Gets or sets the hardware acceleration type.
+ /// </summary>
+ public string HardwareAccelerationType { get; set; }
+
+ /// <summary>
+ /// Gets or sets the FFmpeg path as set by the user via the UI.
+ /// </summary>
+ public string EncoderAppPath { get; set; }
+
+ /// <summary>
+ /// Gets or sets the current FFmpeg path being used by the system and displayed on the transcode page.
+ /// </summary>
+ public string EncoderAppPathDisplay { get; set; }
+
+ /// <summary>
+ /// Gets or sets the VA-API device.
+ /// </summary>
+ public string VaapiDevice { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether tonemapping is enabled.
+ /// </summary>
+ public bool EnableTonemapping { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether VPP tonemapping is enabled.
+ /// </summary>
+ public bool EnableVppTonemapping { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tone-mapping algorithm.
+ /// </summary>
+ public string TonemappingAlgorithm { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tone-mapping mode.
+ /// </summary>
+ public string TonemappingMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tone-mapping range.
+ /// </summary>
+ public string TonemappingRange { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tone-mapping desaturation.
+ /// </summary>
+ public double TonemappingDesat { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tone-mapping peak.
+ /// </summary>
+ public double TonemappingPeak { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tone-mapping parameters.
+ /// </summary>
+ public double TonemappingParam { get; set; }
+
+ /// <summary>
+ /// Gets or sets the VPP tone-mapping brightness.
+ /// </summary>
+ public double VppTonemappingBrightness { get; set; }
+
+ /// <summary>
+ /// Gets or sets the VPP tone-mapping contrast.
+ /// </summary>
+ public double VppTonemappingContrast { get; set; }
+
+ /// <summary>
+ /// Gets or sets the H264 CRF.
+ /// </summary>
+ public int H264Crf { get; set; }
+
+ /// <summary>
+ /// Gets or sets the H265 CRF.
+ /// </summary>
+ public int H265Crf { get; set; }
+
+ /// <summary>
+ /// Gets or sets the encoder preset.
+ /// </summary>
+ public string EncoderPreset { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the framerate is doubled when deinterlacing.
+ /// </summary>
+ public bool DeinterlaceDoubleRate { get; set; }
+
+ /// <summary>
+ /// Gets or sets the deinterlace method.
+ /// </summary>
+ public string DeinterlaceMethod { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether 10bit HEVC decoding is enabled.
+ /// </summary>
+ public bool EnableDecodingColorDepth10Hevc { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether 10bit VP9 decoding is enabled.
+ /// </summary>
+ public bool EnableDecodingColorDepth10Vp9 { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the enhanced NVDEC is enabled.
+ /// </summary>
+ public bool EnableEnhancedNvdecDecoder { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the system native hardware decoder should be used.
+ /// </summary>
+ public bool PreferSystemNativeHwDecoder { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the Intel H264 low-power hardware encoder should be used.
+ /// </summary>
+ public bool EnableIntelLowPowerH264HwEncoder { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the Intel HEVC low-power hardware encoder should be used.
+ /// </summary>
+ public bool EnableIntelLowPowerHevcHwEncoder { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether hardware encoding is enabled.
+ /// </summary>
+ public bool EnableHardwareEncoding { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether HEVC encoding is enabled.
+ /// </summary>
+ public bool AllowHevcEncoding { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether subtitle extraction is enabled.
+ /// </summary>
+ public bool EnableSubtitleExtraction { get; set; }
+
+ /// <summary>
+ /// Gets or sets the codecs hardware encoding is used for.
+ /// </summary>
+ public string[] HardwareDecodingCodecs { get; set; }
+
+ /// <summary>
+ /// Gets or sets the file extensions on-demand metadata based keyframe extraction is enabled for.
+ /// </summary>
+ public string[] AllowOnDemandMetadataBasedKeyframeExtractionForExtensions { get; set; }
}