Merge pull request #1659 from jellyfin/fix_ffmpeg
Fix segment_time_delta value for ffmpeg 4.1
This commit is contained in:
commit
e87d7cfaf3
|
@ -137,10 +137,7 @@ namespace MediaBrowser.Api.Playback
|
|||
/// </summary>
|
||||
private string GetOutputFilePath(StreamState state, EncodingOptions encodingOptions, string outputFileExtension)
|
||||
{
|
||||
var data = GetCommandLineArguments("dummy\\dummy", encodingOptions, state, false);
|
||||
|
||||
data += "-" + (state.Request.DeviceId ?? string.Empty)
|
||||
+ "-" + (state.Request.PlaySessionId ?? string.Empty);
|
||||
var data = $"{state.MediaPath}-{state.UserAgent}-{state.Request.DeviceId}-{state.Request.PlaySessionId}";
|
||||
|
||||
var filename = data.GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
var ext = outputFileExtension.ToLowerInvariant();
|
||||
|
|
|
@ -908,7 +908,9 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
}
|
||||
else
|
||||
{
|
||||
var keyFrameArg = string.Format(" -force_key_frames \"expr:gte(t,n_forced*{0})\"",
|
||||
var keyFrameArg = string.Format(
|
||||
" -force_key_frames:0 \"expr:gte(t,{0}+n_forced*{1})\"",
|
||||
GetStartNumber(state) * state.SegmentLength,
|
||||
state.SegmentLength.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||
|
@ -965,10 +967,10 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
|
||||
var timeDeltaParam = string.Empty;
|
||||
|
||||
if (isEncoding && startNumber > 0)
|
||||
if (isEncoding && state.TargetFramerate > 0)
|
||||
{
|
||||
var startTime = state.SegmentLength * startNumber;
|
||||
timeDeltaParam = string.Format("-segment_time_delta -{0}", startTime);
|
||||
float startTime = 1 / (state.TargetFramerate.Value * 2);
|
||||
timeDeltaParam = string.Format("-segment_time_delta {0}", Math.Round(startTime, 3));
|
||||
}
|
||||
|
||||
var segmentFormat = GetSegmentFileExtension(state.Request).TrimStart('.');
|
||||
|
@ -977,11 +979,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
segmentFormat = "mpegts";
|
||||
}
|
||||
|
||||
var breakOnNonKeyFrames = state.EnableBreakOnNonKeyFrames(videoCodec);
|
||||
|
||||
var breakOnNonKeyFramesArg = breakOnNonKeyFrames ? " -break_non_keyframes 1" : "";
|
||||
|
||||
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{12} -segment_format {11} -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"",
|
||||
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}\"",
|
||||
inputModifier,
|
||||
EncodingHelper.GetInputArgument(state, encodingOptions),
|
||||
threads,
|
||||
|
@ -993,8 +992,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
outputPath,
|
||||
outputTsArg,
|
||||
timeDeltaParam,
|
||||
segmentFormat,
|
||||
breakOnNonKeyFramesArg
|
||||
segmentFormat
|
||||
).Trim();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user