소스 검색

update transcoding for chrome

Luke Pulverenti 9 년 전
부모
커밋
4999b47b47
2개의 변경된 파일25개의 추가작업 그리고 5개의 파일을 삭제
  1. 12 1
      MediaBrowser.Api/Playback/BaseStreamingService.cs
  2. 13 4
      MediaBrowser.Api/Playback/Progressive/VideoService.cs

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

@@ -2178,7 +2178,18 @@ namespace MediaBrowser.Api.Playback
                 inputModifier += " " + videoDecoder;
             }
 
-            //inputModifier += " -noaccurate_seek";
+            if (state.VideoRequest != null)
+            {
+                var videoCodec = GetVideoEncoder(state);
+                // See if we can save come cpu cycles by avoiding encoding
+                if (string.Equals(videoCodec, "copy", StringComparison.OrdinalIgnoreCase))
+                {
+                    if (string.Equals(state.OutputContainer, "mkv", StringComparison.OrdinalIgnoreCase))
+                    {
+                        inputModifier += " -noaccurate_seek";
+                    }
+                }
+            }
             
             return inputModifier;
         }

+ 13 - 4
MediaBrowser.Api/Playback/Progressive/VideoService.cs

@@ -136,11 +136,20 @@ namespace MediaBrowser.Api.Playback.Progressive
             }
 
             // See if we can save come cpu cycles by avoiding encoding
-            if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
+            if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
             {
-                return state.VideoStream != null && IsH264(state.VideoStream) && string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) ?
-                    args + " -bsf:v h264_mp4toannexb" :
-                    args;
+                if (string.Equals(state.OutputContainer, "mkv", StringComparison.OrdinalIgnoreCase))
+                {
+                    //args += " -copyts -avoid_negative_ts disabled -start_at_zero";
+                }
+
+                if (state.VideoStream != null && IsH264(state.VideoStream) &&
+                    (string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) || string.Equals(state.OutputContainer, "mkv", StringComparison.OrdinalIgnoreCase)))
+                {
+                    args += " -bsf:v h264_mp4toannexb";
+                }
+
+                return args;
             }
 
             var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",