minor improvements
This commit is contained in:
parent
0af353404c
commit
95c5c08610
|
@ -942,7 +942,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
// as forcing keyframes is not enough.
|
// as forcing keyframes is not enough.
|
||||||
// Example: we encoded half of desired length, then codec detected
|
// Example: we encoded half of desired length, then codec detected
|
||||||
// scene cut and inserted a keyframe; next forced keyframe would
|
// scene cut and inserted a keyframe; next forced keyframe would
|
||||||
// be created outside of segment, which breaks seeking.
|
// be created outside of segment, which breaks seeking
|
||||||
|
// -sc_threshold 0 is used to prevent the hardware encoder from post processing to break the set keyframe
|
||||||
gopArg = string.Format(
|
gopArg = string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
" -g {0} -keyint_min {0} -sc_threshold 0",
|
" -g {0} -keyint_min {0} -sc_threshold 0",
|
||||||
|
@ -968,17 +969,16 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
|
|
||||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||||
|
|
||||||
// Add resolution params, if specified
|
|
||||||
if (!hasGraphicalSubs)
|
|
||||||
{
|
|
||||||
args += EncodingHelper.GetOutputSizeParam(state, encodingOptions, codec);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is for graphical subs
|
// This is for graphical subs
|
||||||
if (hasGraphicalSubs)
|
if (hasGraphicalSubs)
|
||||||
{
|
{
|
||||||
args += EncodingHelper.GetGraphicalSubtitleParam(state, encodingOptions, codec);
|
args += EncodingHelper.GetGraphicalSubtitleParam(state, encodingOptions, codec);
|
||||||
}
|
}
|
||||||
|
// Add resolution params, if specified
|
||||||
|
else
|
||||||
|
{
|
||||||
|
args += EncodingHelper.GetOutputSizeParam(state, encodingOptions, codec);
|
||||||
|
}
|
||||||
|
|
||||||
// -start_at_zero is necessary to use with -ss when seeking,
|
// -start_at_zero is necessary to use with -ss when seeking,
|
||||||
// otherwise the target position cannot be determined.
|
// otherwise the target position cannot be determined.
|
||||||
|
|
|
@ -1588,9 +1588,11 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
// Setup subtitle scaling
|
// Setup subtitle scaling
|
||||||
if (state.VideoStream != null && state.VideoStream.Width.HasValue && state.VideoStream.Height.HasValue)
|
if (state.VideoStream != null && state.VideoStream.Width.HasValue && state.VideoStream.Height.HasValue)
|
||||||
{
|
{
|
||||||
|
// force_original_aspect_ratio=decrease
|
||||||
|
// Enable decreasing output video width or height if necessary to keep the original aspect ratio
|
||||||
videoSizeParam = string.Format(
|
videoSizeParam = string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
"scale={0}:{1}",
|
"scale={0}:{1}:force_original_aspect_ratio=decrease",
|
||||||
state.VideoStream.Width.Value,
|
state.VideoStream.Width.Value,
|
||||||
state.VideoStream.Height.Value);
|
state.VideoStream.Height.Value);
|
||||||
|
|
||||||
|
@ -1601,6 +1603,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
}
|
}
|
||||||
|
|
||||||
// For VAAPI and CUVID decoder
|
// For VAAPI and CUVID decoder
|
||||||
|
// these encoders cannot automatically adjust the size of graphical subtitles to fit the output video,
|
||||||
|
// thus needs to be manually adjusted.
|
||||||
if (string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase)
|
if (string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase)
|
||||||
|| (videoDecoder ?? string.Empty).IndexOf("cuvid", StringComparison.OrdinalIgnoreCase) != -1)
|
|| (videoDecoder ?? string.Empty).IndexOf("cuvid", StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
{
|
{
|
||||||
|
@ -1613,7 +1617,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
{
|
{
|
||||||
videoSizeParam = string.Format(
|
videoSizeParam = string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
"scale={0}:{1}",
|
"scale={0}:{1}:force_original_aspect_ratio=decrease",
|
||||||
width.Value,
|
width.Value,
|
||||||
height.Value);
|
height.Value);
|
||||||
}
|
}
|
||||||
|
@ -1741,7 +1745,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
|
|
||||||
var hasTextSubs = state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
var hasTextSubs = state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||||
|
|
||||||
if (string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) || (string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) && !hasTextSubs)
|
if (string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) || (string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) && !hasTextSubs)
|
||||||
&& width.HasValue
|
&& width.HasValue
|
||||||
&& height.HasValue)
|
&& height.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -2043,7 +2047,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
else if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
else if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (!hasTextSubs)
|
if (!hasTextSubs)
|
||||||
{
|
{
|
||||||
filters.Add(string.Format(CultureInfo.InvariantCulture, "deinterlace_qsv"));
|
filters.Add(string.Format(CultureInfo.InvariantCulture, "deinterlace_qsv"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2051,9 +2055,9 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
|
|
||||||
// Add software deinterlace filter before scaling filter
|
// Add software deinterlace filter before scaling filter
|
||||||
if (((state.DeInterlace("h264", true) || state.DeInterlace("h265", true) || state.DeInterlace("hevc", true))
|
if (((state.DeInterlace("h264", true) || state.DeInterlace("h265", true) || state.DeInterlace("hevc", true))
|
||||||
&& !string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)
|
&& !string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)
|
||||||
&& !string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
&& !string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||||
|| (hasTextSubs && state.DeInterlace("h264", true) && string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)))
|
|| (hasTextSubs && state.DeInterlace("h264", true) && string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
var inputFramerate = videoStream?.RealFrameRate;
|
var inputFramerate = videoStream?.RealFrameRate;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user