Browse Source

update live tv transcoding params

Luke Pulverenti 8 years ago
parent
commit
7e05f03f09

+ 6 - 1
MediaBrowser.Api/Playback/BaseStreamingService.cs

@@ -352,6 +352,11 @@ namespace MediaBrowser.Api.Playback
             return defaultEncoder;
         }
 
+        protected virtual string GetDefaultH264Preset()
+        {
+            return "superfast";
+        }
+
         /// <summary>
         /// Gets the video bitrate to specify on the command line
         /// </summary>
@@ -375,7 +380,7 @@ namespace MediaBrowser.Api.Playback
                 }
                 else
                 {
-                    param += "-preset superfast";
+                    param += "-preset " + GetDefaultH264Preset();
                 }
 
                 if (encodingOptions.H264Crf >= 0 && encodingOptions.H264Crf <= 51)

+ 6 - 1
MediaBrowser.Api/Playback/Hls/BaseHlsService.cs

@@ -256,7 +256,7 @@ namespace MediaBrowser.Api.Playback.Hls
                     "hls/" + Path.GetFileNameWithoutExtension(outputPath));
             }
 
-            var args = string.Format("{0} {1} {2} -map_metadata -1 -threads {3} {4} {5} -sc_threshold 0 {6} -hls_time {7} -start_number {8} -hls_list_size {9}{10} -y \"{11}\"",
+            var args = string.Format("{0} {1} {2} -map_metadata -1 -threads {3} {4} {5} -avoid_negative_ts make_zero -fflags +genpts -sc_threshold 0 {6} -hls_time {7} -start_number {8} -hls_list_size {9}{10} -y \"{11}\"",
                 itsOffset,
                 inputModifier,
                 GetInputArgument(state),
@@ -274,6 +274,11 @@ namespace MediaBrowser.Api.Playback.Hls
             return args;
         }
 
+        protected override string GetDefaultH264Preset()
+        {
+            return "veryfast";
+        }
+
         protected virtual int GetStartNumber(StreamState state)
         {
             return 0;

+ 2 - 1
MediaBrowser.Api/Playback/Hls/VideoHlsService.cs

@@ -91,6 +91,7 @@ namespace MediaBrowser.Api.Playback.Hls
                 {
                     args += " -bsf:v h264_mp4toannexb";
                 }
+                args += " -flags +global_header";
                 return args;
             }
 
@@ -113,7 +114,7 @@ namespace MediaBrowser.Api.Playback.Hls
                 args += GetGraphicalSubtitleParam(state, codec);
             }
 
-            args += " -flags -global_header";
+            args += " -flags +global_header";
 
             return args;
         }

+ 10 - 0
MediaBrowser.Api/Playback/Progressive/VideoService.cs

@@ -150,6 +150,11 @@ namespace MediaBrowser.Api.Playback.Progressive
                     args += " -copyts -avoid_negative_ts disabled -start_at_zero";
                 }
 
+                if (!state.RunTimeTicks.HasValue)
+                {
+                    args += " -fflags +genpts -flags +global_header";
+                }
+
                 return args;
             }
 
@@ -191,6 +196,11 @@ namespace MediaBrowser.Api.Playback.Progressive
                 args += GetGraphicalSubtitleParam(state, videoCodec);
             }
 
+            if (!state.RunTimeTicks.HasValue)
+            {
+                args += " -fflags +genpts -flags +global_header";
+            }
+
             return args;
         }
 

+ 1 - 6
MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs

@@ -159,15 +159,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
 
         private async Task AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio, CancellationToken cancellationToken)
         {
-            var originalRuntime = mediaSource.RunTimeTicks;
-
             mediaSource.DefaultSubtitleStreamIndex = null;
 
             // Null this out so that it will be treated like a live stream
-            if (!originalRuntime.HasValue)
-            {
-                mediaSource.RunTimeTicks = null;
-            }
+            mediaSource.RunTimeTicks = null;
 
             var audioStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == Model.Entities.MediaStreamType.Audio);