From 36a34f911ef8b5c18c51de8a6761b0947784a525 Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 27 Sep 2019 16:37:41 +0300 Subject: [PATCH 1/2] Replaced "stream" muxer with "hls" trying to fix "premature stop" issue --- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index f5f7536843..73a407963f 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -967,11 +967,14 @@ namespace MediaBrowser.Api.Playback.Hls var timeDeltaParam = string.Empty; + // disabled in HLS ffmpeg muxer + /* if (isEncoding && state.TargetFramerate > 0) { float startTime = 1 / (state.TargetFramerate.Value * 2); timeDeltaParam = string.Format(CultureInfo.InvariantCulture, "-segment_time_delta {0:F3}", startTime); } + */ var segmentFormat = GetSegmentFileExtension(state.Request).TrimStart('.'); if (string.Equals(segmentFormat, "ts", StringComparison.OrdinalIgnoreCase)) @@ -980,7 +983,7 @@ namespace MediaBrowser.Api.Playback.Hls } return string.Format( - "{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time {6} {10} -individual_header_trailer 0 -segment_format {11} -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"", + "{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -f hls -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -hls_time {6} {10} -individual_header_trailer 0 -hls_segment_type {11} -start_number {7} -hls_segment_filename \"{9}\" -hls_playlist_type vod -hls_list_size 0 -y \"{8}\"", inputModifier, EncodingHelper.GetInputArgument(state, encodingOptions), threads, From 4fae733eefaa59cc1392a8c1ec9bf1abade1020e Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 27 Sep 2019 18:22:43 +0300 Subject: [PATCH 2/2] Cleaned up move to HLS muxer --- .../Playback/Hls/DynamicHlsService.cs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 73a407963f..8fa6c3dac0 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -965,17 +965,6 @@ namespace MediaBrowser.Api.Playback.Hls var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request); - var timeDeltaParam = string.Empty; - - // disabled in HLS ffmpeg muxer - /* - if (isEncoding && state.TargetFramerate > 0) - { - float startTime = 1 / (state.TargetFramerate.Value * 2); - timeDeltaParam = string.Format(CultureInfo.InvariantCulture, "-segment_time_delta {0:F3}", startTime); - } - */ - var segmentFormat = GetSegmentFileExtension(state.Request).TrimStart('.'); if (string.Equals(segmentFormat, "ts", StringComparison.OrdinalIgnoreCase)) { @@ -983,7 +972,7 @@ namespace MediaBrowser.Api.Playback.Hls } return string.Format( - "{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -f hls -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -hls_time {6} {10} -individual_header_trailer 0 -hls_segment_type {11} -start_number {7} -hls_segment_filename \"{9}\" -hls_playlist_type vod -hls_list_size 0 -y \"{8}\"", + "{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -f hls -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -hls_time {6} -individual_header_trailer 0 -hls_segment_type {7} -start_number {8} -hls_segment_filename \"{9}\" -hls_playlist_type vod -hls_list_size 0 -y \"{10}\"", inputModifier, EncodingHelper.GetInputArgument(state, encodingOptions), threads, @@ -991,11 +980,10 @@ namespace MediaBrowser.Api.Playback.Hls GetVideoArguments(state, encodingOptions), GetAudioArguments(state, encodingOptions), state.SegmentLength.ToString(CultureInfo.InvariantCulture), + segmentFormat, startNumberParam, - outputPath, outputTsArg, - timeDeltaParam, - segmentFormat + outputPath ).Trim(); } }