Clean up deprecated -vsync option (#12765)

This commit is contained in:
Nyanmisaka 2024-10-03 14:18:40 +00:00 committed by GitHub
parent 9604088e3c
commit b496f979f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 34 additions and 6 deletions

View File

@ -1908,7 +1908,7 @@ public class DynamicHlsController : BaseJellyfinApiController
if (!string.IsNullOrEmpty(state.OutputVideoSync)) if (!string.IsNullOrEmpty(state.OutputVideoSync))
{ {
args += " -vsync " + state.OutputVideoSync; args += EncodingHelper.GetVideoSyncOption(state.OutputVideoSync, _mediaEncoder.EncoderVersion);
} }
args += _encodingHelper.GetOutputFFlags(state); args += _encodingHelper.GetOutputFFlags(state);

View File

@ -6857,7 +6857,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (!string.IsNullOrEmpty(state.InputVideoSync)) if (!string.IsNullOrEmpty(state.InputVideoSync))
{ {
inputModifier += " -vsync " + state.InputVideoSync; inputModifier += GetVideoSyncOption(state.InputVideoSync, _mediaEncoder.EncoderVersion);
} }
if (state.ReadInputAtNativeFramerate && state.InputProtocol != MediaProtocol.Rtsp) if (state.ReadInputAtNativeFramerate && state.InputProtocol != MediaProtocol.Rtsp)
@ -7280,7 +7280,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (!string.IsNullOrEmpty(state.OutputVideoSync)) if (!string.IsNullOrEmpty(state.OutputVideoSync))
{ {
args += " -vsync " + state.OutputVideoSync; args += GetVideoSyncOption(state.OutputVideoSync, _mediaEncoder.EncoderVersion);
} }
args += GetOutputFFlags(state); args += GetOutputFFlags(state);
@ -7453,5 +7453,33 @@ namespace MediaBrowser.Controller.MediaEncoding
return state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode return state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode
|| (state.BaseRequest.AlwaysBurnInSubtitleWhenTranscoding && !IsCopyCodec(state.OutputVideoCodec)); || (state.BaseRequest.AlwaysBurnInSubtitleWhenTranscoding && !IsCopyCodec(state.OutputVideoCodec));
} }
public static string GetVideoSyncOption(string videoSync, Version encoderVersion)
{
if (string.IsNullOrEmpty(videoSync))
{
return string.Empty;
}
if (encoderVersion >= new Version(5, 1))
{
if (int.TryParse(videoSync, CultureInfo.InvariantCulture, out var vsync))
{
return vsync switch
{
-1 => " -fps_mode auto",
0 => " -fps_mode passthrough",
1 => " -fps_mode cfr",
2 => " -fps_mode vfr",
_ => string.Empty
};
}
return string.Empty;
}
// -vsync is deprecated in FFmpeg 5.1 and will be removed in the future.
return $" -vsync {videoSync}";
}
} }
} }

View File

@ -945,7 +945,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
vidEncoder, vidEncoder,
encoderQualityOption + encoderQuality + " ", encoderQualityOption + encoderQuality + " ",
vidEncoder.Contains("videotoolbox", StringComparison.InvariantCultureIgnoreCase) ? "-allow_sw 1 " : string.Empty, // allow_sw fallback for some intel macs vidEncoder.Contains("videotoolbox", StringComparison.InvariantCultureIgnoreCase) ? "-allow_sw 1 " : string.Empty, // allow_sw fallback for some intel macs
EncoderVersion >= new Version(5, 1) ? "-fps_mode passthrough " : "-vsync passthrough ", // passthrough timestamp EncodingHelper.GetVideoSyncOption("0", EncoderVersion).Trim() + " ", // passthrough timestamp
"image2", "image2",
outputPath); outputPath);

View File

@ -130,7 +130,7 @@ namespace Jellyfin.LiveTv.IO
const int MaxBitrate = 25000000; const int MaxBitrate = 25000000;
videoArgs = string.Format( videoArgs = string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"-codec:v:0 libx264 -force_key_frames \"expr:gte(t,n_forced*5)\" {0} -pix_fmt yuv420p -preset superfast -crf 23 -b:v {1} -maxrate {1} -bufsize ({1}*2) -vsync -1 -profile:v high -level 41", "-codec:v:0 libx264 -force_key_frames \"expr:gte(t,n_forced*5)\" {0} -pix_fmt yuv420p -preset superfast -crf 23 -b:v {1} -maxrate {1} -bufsize ({1}*2) -profile:v high -level 41",
GetOutputSizeParam(), GetOutputSizeParam(),
MaxBitrate); MaxBitrate);
} }
@ -157,7 +157,7 @@ namespace Jellyfin.LiveTv.IO
flags.Add("+genpts"); flags.Add("+genpts");
} }
var inputModifier = "-async 1 -vsync -1"; var inputModifier = "-async 1";
if (flags.Count > 0) if (flags.Count > 0)
{ {