diff options
| -rw-r--r-- | MediaBrowser.Api/Playback/BaseStreamingService.cs | 53 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Hls/BaseHlsService.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Progressive/AudioService.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Progressive/VideoService.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/StreamState.cs | 8 |
5 files changed, 69 insertions, 16 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 9c147379a..3a72ced17 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -622,7 +622,7 @@ namespace MediaBrowser.Api.Playback /// <param name="videoType">Type of the video.</param> /// <param name="isoType">Type of the iso.</param> /// <returns>System.String.</returns> - 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 /// </summary> /// <param name="path">The path.</param> /// <returns>System.String.</returns> - protected string GetUserAgentParam(string path) + private string GetUserAgentParam(string path) { var useragent = GetUserAgent(path); @@ -1059,9 +1059,10 @@ namespace MediaBrowser.Api.Playback } //state.RunTimeTicks = recording.RunTimeTicks; - state.SendInputOverStandardInput = recording.RecordingInfo.Status == RecordingStatus.InProgress; + state.ReadInputAtNativeFramerate = recording.RecordingInfo.Status == RecordingStatus.InProgress; state.AudioSync = 1000; state.DeInterlace = true; + state.InputFormat = "mpegts"; } else if (item is LiveTvChannel) { @@ -1087,8 +1088,12 @@ namespace MediaBrowser.Api.Playback } state.SendInputOverStandardInput = true; + state.ReadInputAtNativeFramerate = true; state.AudioSync = 1000; state.DeInterlace = true; + state.InputFormat = "mpegts"; + + await Task.Delay(1000, cancellationToken).ConfigureAwait(false); } else { @@ -1140,6 +1145,48 @@ namespace MediaBrowser.Api.Playback return state; } + protected string GetInputModifier(StreamState state) + { + 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; + } + + if (!string.IsNullOrEmpty(state.InputVideoCodec)) + { + inputModifier += " -vcodec " + state.InputVideoCodec; + } + + if (!string.IsNullOrEmpty(state.InputAudioCodec)) + { + inputModifier += " -acodec " + state.InputAudioCodec; + } + + if (state.ReadInputAtNativeFramerate) + { + inputModifier += " -re"; + } + + return inputModifier; + } + /// <summary> /// Infers the audio codec based on the url /// </summary> diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index b2fb9c1eb..b162d582d 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -262,8 +262,6 @@ namespace MediaBrowser.Api.Playback.Hls /// <returns>System.String.</returns> 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 @@ -274,11 +272,11 @@ namespace MediaBrowser.Api.Playback.Hls var threads = GetNumberOfThreads(false); - var args = string.Format("{0}{1} {2} {3} -fflags genpts -i {4}{5} -map_metadata -1 -threads {6} {7} {8} -sc_threshold 0 {9} -hls_time {10} -start_number 0 -hls_list_size 1440 \"{11}\"", + var inputModifier = GetInputModifier(state); + + 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), threads, diff --git a/MediaBrowser.Api/Playback/Progressive/AudioService.cs b/MediaBrowser.Api/Playback/Progressive/AudioService.cs index a7ef684a5..526f81df7 100644 --- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs +++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs @@ -104,8 +104,10 @@ namespace MediaBrowser.Api.Playback.Progressive var threads = GetNumberOfThreads(false); + var inputModifier = GetInputModifier(state); + return string.Format("{0} -i {1}{2} -threads {3}{4} {5} -id3v2_version 3 -write_id3v1 1 \"{6}\"", - GetFastSeekCommandLineParameter(request), + inputModifier, GetInputArgument(state), GetSlowSeekCommandLineParameter(request), threads, diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index 065a0112b..826b03440 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -91,8 +91,6 @@ namespace MediaBrowser.Api.Playback.Progressive /// <returns>System.String.</returns> 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); @@ -106,10 +104,10 @@ namespace MediaBrowser.Api.Playback.Progressive var threads = GetNumberOfThreads(string.Equals(videoCodec, "libvpx", StringComparison.OrdinalIgnoreCase)); - return string.Format("{0} {1} {2} -fflags genpts -i {3}{4}{5} {6} {7} -map_metadata -1 -threads {8} {9}{10} \"{11}\"", - probeSize, - GetUserAgentParam(state.MediaPath), - GetFastSeekCommandLineParameter(state.Request), + var inputModifier = GetInputModifier(state); + + return string.Format("{0} -i {1}{2}{3} {4} {5} -map_metadata -1 -threads {6} {7}{8} \"{9}\"", + inputModifier, GetInputArgument(state), GetSlowSeekCommandLineParameter(state.Request), keyFrame, diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index 5ade8e43a..1794ebd16 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -62,5 +62,13 @@ namespace MediaBrowser.Api.Playback public int AudioSync = 1; public bool DeInterlace { get; set; } + + public bool ReadInputAtNativeFramerate { get; set; } + + public string InputFormat { get; set; } + + public string InputVideoCodec { get; set; } + + public string InputAudioCodec { get; set; } } } |
