Add comments

This commit is contained in:
Petr Janda 2019-12-05 18:39:09 +10:30
parent 78a161138f
commit 3d8f3da5d6

View File

@ -1582,6 +1582,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var videoSizeParam = string.Empty; var videoSizeParam = string.Empty;
// 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)
{ {
videoSizeParam = string.Format( videoSizeParam = string.Format(
@ -1592,6 +1593,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
{ {
//For QSV, feed it into hardware encoder
videoSizeParam += ",hwupload=extra_hw_frames=64"; videoSizeParam += ",hwupload=extra_hw_frames=64";
} }
else else
@ -1609,10 +1611,17 @@ namespace MediaBrowser.Controller.MediaEncoding
: state.SubtitleStream.Index; : state.SubtitleStream.Index;
var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options); var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options);
// Setup default filtergraph utilizing FFMpeg overlay() and FFMpeg scale() (see the return of this function for index reference)
var retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\""; var retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\"";
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)) if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
{ {
/*
QSV in FFMpeg can now setup hardware overlay for transcodes.
For software decoding and hardware encoding option, frames must be hwuploaded into hardware
with fixed frame size.
*/
if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv")) if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv"))
{ {
retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\""; retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\"";
@ -1705,6 +1714,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|| !videoHeight.HasValue || !videoHeight.HasValue
|| outputHeight != videoHeight.Value) || outputHeight != videoHeight.Value)
{ {
//Force nv12 pixel format to enable 10-bit to 8-bit colour conversion.
filters.Add( filters.Add(
string.Format( string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,