Parcourir la source

Set input readrate for using SegmentDeletion with stream-copy

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
nyanmisaka il y a 1 an
Parent
commit
39b953e41c
1 fichiers modifiés avec 13 ajouts et 1 suppressions
  1. 13 1
      MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs

+ 13 - 1
MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs

@@ -51,6 +51,8 @@ namespace MediaBrowser.Controller.MediaEncoding
         private readonly Version _minFFmpegOclCuTonemapMode = new Version(5, 1, 3);
         private readonly Version _minFFmpegSvtAv1Params = new Version(5, 1);
         private readonly Version _minFFmpegVaapiH26xEncA53CcSei = new Version(6, 0);
+        private readonly Version _minFFmpegAutoscaleOption = new Version(4, 4);
+        private readonly Version _minFFmpegReadrateOption = new Version(5, 0);
 
         private static readonly string[] _videoProfilesH264 = new[]
         {
@@ -1221,7 +1223,7 @@ namespace MediaBrowser.Controller.MediaEncoding
 
             // Disable auto inserted SW scaler for HW decoders in case of changed resolution.
             var isSwDecoder = string.IsNullOrEmpty(GetHardwareVideoDecoder(state, options));
-            if (!isSwDecoder && _mediaEncoder.EncoderVersion >= new Version(4, 4))
+            if (!isSwDecoder && _mediaEncoder.EncoderVersion >= _minFFmpegAutoscaleOption)
             {
                 arg.Append(" -noautoscale");
             }
@@ -6393,6 +6395,16 @@ namespace MediaBrowser.Controller.MediaEncoding
             {
                 inputModifier += " -re";
             }
+            else if (encodingOptions.EnableSegmentDeletion
+                && state.VideoStream is not null
+                && state.TranscodingType == TranscodingJobType.Hls
+                && IsCopyCodec(state.OutputVideoCodec)
+                && _mediaEncoder.EncoderVersion >= _minFFmpegReadrateOption)
+            {
+                // Set an input read rate limit 10x for using SegmentDeletion with stream-copy
+                // to prevent ffmpeg from exiting prematurely (due to fast drive)
+                inputModifier += " -readrate 10";
+            }
 
             var flags = new List<string>();
             if (state.IgnoreInputDts)