From 3132280b0748efd6ded7d8c9d8795506ef8c30ed Mon Sep 17 00:00:00 2001 From: Vasily Date: Mon, 14 Oct 2019 13:13:04 +0300 Subject: [PATCH] * Make sure force_key_frames expression arguments are properly converted to strings * Fore usage of keyframe cuts only in HLS --- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 8cbe4af1e8..1b93eaaa57 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -925,7 +925,7 @@ namespace MediaBrowser.Api.Playback.Hls { var keyFrameArg = string.Format( " -force_key_frames:0 \"expr:gte(t,{0}+n_forced*{1})\"", - GetStartNumber(state) * state.SegmentLength, + (GetStartNumber(state) * state.SegmentLength).ToString(CultureInfo.InvariantCulture), state.SegmentLength.ToString(CultureInfo.InvariantCulture)); if (state.TargetFramerate.HasValue) { @@ -936,7 +936,7 @@ namespace MediaBrowser.Api.Playback.Hls // be created outside of segment, which breaks seeking. keyFrameArg += string.Format( " -g {0} -keyint_min {0}", - (int)(state.SegmentLength * state.TargetFramerate) + ((int)(state.SegmentLength * state.TargetFramerate)).ToString(CultureInfo.InvariantCulture) ); } @@ -982,6 +982,15 @@ namespace MediaBrowser.Api.Playback.Hls var threads = EncodingHelper.GetNumberOfThreads(state, encodingOptions, videoCodec); + if (state.BaseRequest.BreakOnNonKeyFrames) + { + // FIXME: this is actually a workaround, as ideally it really should be the client which decides whether non-keyframe + // breakpoints are supported; but current implementation always uses "ffmpeg input seeking" which is liable + // to produce a missing part of video stream before first keyframe is encountered, which may lead to + // awkward cases like a few starting HLS segments having no video whatsoever, which breaks hls.js + Logger.LogInformation("Current HLS implementation doesn't support non-keyframe breaks but one is requested, ignoring that request"); + state.BaseRequest.BreakOnNonKeyFrames = false; + } var inputModifier = EncodingHelper.GetInputModifier(state, encodingOptions); // If isEncoding is true we're actually starting ffmpeg