diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index c6bcbded8..fea44c9a8 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -265,7 +265,7 @@ namespace MediaBrowser.Api.Playback if (cpuCount >= 4) { - return EncodingQuality.HighQuality; + //return EncodingQuality.HighQuality; } return EncodingQuality.HighSpeed; @@ -1418,6 +1418,9 @@ namespace MediaBrowser.Api.Playback state.HasMediaStreams = mediaStreams.Count > 0; + state.SegmentLength = state.ReadInputAtNativeFramerate ? 3 : 10; + state.HlsListSize = state.ReadInputAtNativeFramerate ? 20 : 1440; + return state; } diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index c6055ed51..5324d2c80 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -285,7 +285,7 @@ namespace MediaBrowser.Api.Playback.Hls // If performSubtitleConversions is true we're actually starting ffmpeg var startNumberParam = performSubtitleConversions ? GetStartNumber(state).ToString(UsCulture) : "0"; - 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 {9} -hls_list_size 1440 \"{10}\"", + 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 {9} -hls_list_size {10} \"{11}\"", itsOffset, inputModifier, GetInputArgument(state), @@ -296,6 +296,7 @@ namespace MediaBrowser.Api.Playback.Hls GetAudioArguments(state), state.SegmentLength.ToString(UsCulture), startNumberParam, + state.HlsListSize.ToString(UsCulture), outputPath ).Trim(); @@ -307,11 +308,12 @@ namespace MediaBrowser.Api.Playback.Hls var bitrate = hlsVideoRequest.BaselineStreamAudioBitRate ?? 64000; - var lowBitrateParams = string.Format(" -threads {0} -vn -codec:a:0 libmp3lame -ac 2 -ab {1} -hls_time {2} -start_number {3} -hls_list_size 1440 \"{4}\"", + var lowBitrateParams = string.Format(" -threads {0} -vn -codec:a:0 libmp3lame -ac 2 -ab {1} -hls_time {2} -start_number {3} -hls_list_size {4} \"{5}\"", threads, bitrate / 2, state.SegmentLength.ToString(UsCulture), startNumberParam, + state.HlsListSize.ToString(UsCulture), lowBitratePath); args += " " + lowBitrateParams; diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index ca598c275..a2080995d 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -163,7 +163,9 @@ namespace MediaBrowser.Api.Playback.Hls return IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf h264_mp4toannexb" : "-codec:v:0 copy"; } - const string keyFrameArg = " -force_key_frames expr:if(isnan(prev_forced_t),gte(t,.1),gte(t,prev_forced_t+5))"; + var keyFrameArg = state.ReadInputAtNativeFramerate ? + " -force_key_frames expr:if(isnan(prev_forced_t),gte(t,.1),gte(t,prev_forced_t+1))" : + " -force_key_frames expr:if(isnan(prev_forced_t),gte(t,.1),gte(t,prev_forced_t+5))"; var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsExternal && (state.SubtitleStream.Codec.IndexOf("pgs", StringComparison.OrdinalIgnoreCase) != -1 || diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index 55d7b22e2..3874fa603 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -56,6 +56,7 @@ namespace MediaBrowser.Api.Playback public string LiveTvStreamId { get; set; } public int SegmentLength = 10; + public int HlsListSize; public long? RunTimeTicks;