From 3d697cdab27baa33c9d00785fce6de4c448d6028 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 21 Jan 2014 20:37:01 -0500 Subject: [PATCH] added new stream info properties --- .../Playback/BaseStreamingService.cs | 32 ++++++++++++++++++- .../Playback/Hls/BaseHlsService.cs | 5 ++- .../Playback/Progressive/AudioService.cs | 5 ++- .../Playback/Progressive/VideoService.cs | 5 ++- MediaBrowser.Api/Playback/StreamState.cs | 8 +++++ 5 files changed, 51 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 9c147379a..10ef902d9 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -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,10 @@ namespace MediaBrowser.Api.Playback } state.SendInputOverStandardInput = true; + state.ReadInputAtNativeFramerate = true; state.AudioSync = 1000; state.DeInterlace = true; + state.InputFormat = "mpegts"; } else { @@ -1140,6 +1143,33 @@ namespace MediaBrowser.Api.Playback return state; } + protected string GetInputModifier(StreamState state) + { + var inputModifier = string.Empty; + + 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; + } + /// /// Infers the audio codec based on the url /// diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index b2fb9c1eb..a1d1854b8 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -274,11 +274,14 @@ 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} {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}\"", 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..7dd5eda68 100644 --- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs +++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs @@ -104,8 +104,11 @@ namespace MediaBrowser.Api.Playback.Progressive var threads = GetNumberOfThreads(false); - return string.Format("{0} -i {1}{2} -threads {3}{4} {5} -id3v2_version 3 -write_id3v1 1 \"{6}\"", + 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), + inputModifier, GetInputArgument(state), GetSlowSeekCommandLineParameter(request), threads, diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index 065a0112b..01dd5d8b1 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -106,10 +106,13 @@ 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}\"", + 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), + 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; } } }