From cf1dac60f632646fa6ccdc715eee9fa5cf240bf3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 21 Jan 2014 22:07:33 -0500 Subject: [PATCH] relocate more ffmpeg params. add channel delay --- .../Playback/BaseStreamingService.cs | 23 ++++++++++++++++--- .../Playback/Hls/BaseHlsService.cs | 7 +----- .../Playback/Progressive/AudioService.cs | 3 +-- .../Playback/Progressive/VideoService.cs | 7 +----- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 10ef902d9e..3a72ced17a 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -622,7 +622,7 @@ namespace MediaBrowser.Api.Playback /// Type of the video. /// Type of the iso. /// System.String. - protected string GetProbeSizeArgument(string mediaPath, bool isVideo, VideoType? videoType, IsoType? isoType) + private string GetProbeSizeArgument(string mediaPath, bool isVideo, VideoType? videoType, IsoType? isoType) { var type = !isVideo ? MediaEncoderHelpers.GetInputType(null, null) : MediaEncoderHelpers.GetInputType(videoType, isoType); @@ -918,7 +918,7 @@ namespace MediaBrowser.Api.Playback /// /// The path. /// System.String. - protected string GetUserAgentParam(string path) + private string GetUserAgentParam(string path) { var useragent = GetUserAgent(path); @@ -1092,6 +1092,8 @@ namespace MediaBrowser.Api.Playback state.AudioSync = 1000; state.DeInterlace = true; state.InputFormat = "mpegts"; + + await Task.Delay(1000, cancellationToken).ConfigureAwait(false); } else { @@ -1147,6 +1149,21 @@ namespace MediaBrowser.Api.Playback { var inputModifier = string.Empty; + var probeSize = GetProbeSizeArgument(state.MediaPath, state.IsInputVideo, state.VideoType, state.IsoType); + inputModifier += " " + probeSize; + inputModifier = inputModifier.Trim(); + + inputModifier += " " + GetUserAgentParam(state.MediaPath); + inputModifier = inputModifier.Trim(); + + inputModifier += " " + GetFastSeekCommandLineParameter(state.Request); + inputModifier = inputModifier.Trim(); + + if (state.VideoRequest != null) + { + inputModifier += " -fflags genpts"; + } + if (!string.IsNullOrEmpty(state.InputFormat)) { inputModifier += " -f " + state.InputFormat; @@ -1161,7 +1178,7 @@ namespace MediaBrowser.Api.Playback { inputModifier += " -acodec " + state.InputAudioCodec; } - + if (state.ReadInputAtNativeFramerate) { inputModifier += " -re"; diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index a1d1854b84..b162d582d8 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -262,8 +262,6 @@ namespace MediaBrowser.Api.Playback.Hls /// System.String. protected override string GetCommandLineArguments(string outputPath, StreamState state, bool performSubtitleConversions) { - var probeSize = GetProbeSizeArgument(state.MediaPath, state.IsInputVideo, state.VideoType, state.IsoType); - var hlsVideoRequest = state.VideoRequest as GetHlsVideoStream; var itsOffsetMs = hlsVideoRequest == null @@ -276,11 +274,8 @@ namespace MediaBrowser.Api.Playback.Hls var inputModifier = GetInputModifier(state); - var args = string.Format("{0}{1} {2} {3} -fflags genpts{4} -i {5}{6} -map_metadata -1 -threads {7} {8} {9} -sc_threshold 0 {10} -hls_time {11} -start_number 0 -hls_list_size 1440 \"{12}\"", + var args = string.Format("{0} {1} -i {2}{3} -map_metadata -1 -threads {4} {5} {6} -sc_threshold 0 {7} -hls_time {8} -start_number 0 -hls_list_size 1440 \"{9}\"", itsOffset, - probeSize, - GetUserAgentParam(state.MediaPath), - GetFastSeekCommandLineParameter(state.Request), inputModifier, GetInputArgument(state), GetSlowSeekCommandLineParameter(state.Request), diff --git a/MediaBrowser.Api/Playback/Progressive/AudioService.cs b/MediaBrowser.Api/Playback/Progressive/AudioService.cs index 7dd5eda68c..526f81df72 100644 --- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs +++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs @@ -106,8 +106,7 @@ namespace MediaBrowser.Api.Playback.Progressive var inputModifier = GetInputModifier(state); - return string.Format("{0}{1} -i {2}{3} -threads {4}{5} {6} -id3v2_version 3 -write_id3v1 1 \"{7}\"", - GetFastSeekCommandLineParameter(request), + return string.Format("{0} -i {1}{2} -threads {3}{4} {5} -id3v2_version 3 -write_id3v1 1 \"{6}\"", inputModifier, GetInputArgument(state), GetSlowSeekCommandLineParameter(request), diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index 01dd5d8b15..826b034408 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -91,8 +91,6 @@ namespace MediaBrowser.Api.Playback.Progressive /// System.String. protected override string GetCommandLineArguments(string outputPath, StreamState state, bool performSubtitleConversions) { - var probeSize = GetProbeSizeArgument(state.MediaPath, state.IsInputVideo, state.VideoType, state.IsoType); - // Get the output codec name var videoCodec = GetVideoCodec(state.VideoRequest); @@ -108,10 +106,7 @@ namespace MediaBrowser.Api.Playback.Progressive var inputModifier = GetInputModifier(state); - return string.Format("{0} {1} {2} -fflags genpts{3} -i {4}{5}{6} {7} {8} -map_metadata -1 -threads {9} {10}{11} \"{12}\"", - probeSize, - GetUserAgentParam(state.MediaPath), - GetFastSeekCommandLineParameter(state.Request), + return string.Format("{0} -i {1}{2}{3} {4} {5} -map_metadata -1 -threads {6} {7}{8} \"{9}\"", inputModifier, GetInputArgument(state), GetSlowSeekCommandLineParameter(state.Request),