update hls params
This commit is contained in:
parent
52a183804a
commit
20e090e145
|
@ -395,8 +395,6 @@ namespace MediaBrowser.Api.Playback
|
|||
{
|
||||
param += " -crf 23";
|
||||
}
|
||||
|
||||
param += " -tune zerolatency";
|
||||
}
|
||||
|
||||
else if (string.Equals(videoEncoder, "libx265", StringComparison.OrdinalIgnoreCase))
|
||||
|
@ -536,6 +534,11 @@ namespace MediaBrowser.Api.Playback
|
|||
}
|
||||
}
|
||||
|
||||
if (string.Equals(videoEncoder, "libx264", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
param += " -x264opts:0 subme=0:rc_lookahead=10:me_range=4:me=dia:no_chroma_me:8x8dct=0:partitions=none";
|
||||
}
|
||||
|
||||
if (!string.Equals(videoEncoder, "h264_omx", StringComparison.OrdinalIgnoreCase) &&
|
||||
!string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) &&
|
||||
!string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
|
||||
|
|
|
@ -348,6 +348,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
return;
|
||||
}
|
||||
|
||||
Logger.Debug("Deleting partial HLS file {0}", file.FullName);
|
||||
|
||||
try
|
||||
{
|
||||
FileSystem.DeleteFile(file.FullName);
|
||||
|
@ -723,7 +725,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
|
||||
foreach (var length in segmentLengths)
|
||||
{
|
||||
builder.AppendLine("#EXTINF:" + length.ToString("0.0000", UsCulture) + ",");
|
||||
builder.AppendLine("#EXTINF:" + length.ToString("0.0000", UsCulture) + ", nodesc");
|
||||
|
||||
builder.AppendLine(string.Format("hls1/{0}/{1}{2}{3}",
|
||||
|
||||
|
@ -826,7 +828,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
args += " -bsf:v h264_mp4toannexb";
|
||||
}
|
||||
|
||||
args += " -flags -global_header";
|
||||
//args += " -flags -global_header";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -851,7 +853,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
args += GetGraphicalSubtitleParam(state, codec);
|
||||
}
|
||||
|
||||
args += " -flags -global_header";
|
||||
//args += " -flags -global_header";
|
||||
}
|
||||
|
||||
if (EnableCopyTs(state) && args.IndexOf("-copyts", StringComparison.OrdinalIgnoreCase) == -1)
|
||||
|
@ -875,27 +877,25 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
var inputModifier = GetInputModifier(state, false);
|
||||
|
||||
// If isEncoding is true we're actually starting ffmpeg
|
||||
var startNumberParam = isEncoding ? GetStartNumber(state).ToString(UsCulture) : "0";
|
||||
|
||||
var toTimeParam = string.Empty;
|
||||
var timestampOffsetParam = string.Empty;
|
||||
|
||||
if (state.IsOutputVideo && !EnableCopyTs(state) && !string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase) && (state.Request.StartTimeTicks ?? 0) > 0)
|
||||
{
|
||||
timestampOffsetParam = " -output_ts_offset " + MediaEncoder.GetTimeParameter(state.Request.StartTimeTicks ?? 0);
|
||||
}
|
||||
var startNumber = GetStartNumber(state);
|
||||
var startNumberParam = isEncoding ? startNumber.ToString(UsCulture) : "0";
|
||||
|
||||
var mapArgs = state.IsOutputVideo ? GetMapArgs(state) : string.Empty;
|
||||
var enableSplittingOnNonKeyFrames = string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase) && false;
|
||||
var useGenericSegmenter = true;
|
||||
|
||||
// TODO: check libavformat version for 57 50.100 and use -hls_flags split_by_time
|
||||
var hlsProtocolSupportsSplittingByTime = false;
|
||||
|
||||
if (enableSplittingOnNonKeyFrames && !hlsProtocolSupportsSplittingByTime)
|
||||
if (useGenericSegmenter)
|
||||
{
|
||||
var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state);
|
||||
|
||||
return string.Format("{0} {10} {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} -break_non_keyframes 1 -segment_format mpegts -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"",
|
||||
var timeDeltaParam = String.Empty;
|
||||
|
||||
if (isEncoding && startNumber > 0)
|
||||
{
|
||||
var startTime = state.SegmentLength * startNumber;
|
||||
timeDeltaParam = string.Format("-segment_time_delta -{0}", startTime);
|
||||
}
|
||||
|
||||
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 mpegts -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"",
|
||||
inputModifier,
|
||||
GetInputArgument(state),
|
||||
threads,
|
||||
|
@ -906,27 +906,21 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
startNumberParam,
|
||||
outputPath,
|
||||
outputTsArg,
|
||||
toTimeParam
|
||||
timeDeltaParam
|
||||
).Trim();
|
||||
}
|
||||
|
||||
var splitByTime = hlsProtocolSupportsSplittingByTime && enableSplittingOnNonKeyFrames;
|
||||
var splitByTimeArg = splitByTime ? " -hls_flags split_by_time" : "";
|
||||
|
||||
return string.Format("{0}{12} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4}{5} {6} -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -hls_time {7}{8} -start_number {9} -hls_list_size {10} -y \"{11}\"",
|
||||
return string.Format("{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -hls_time {6} -individual_header_trailer 0 -start_number {7} -hls_list_size {8} -y \"{9}\"",
|
||||
inputModifier,
|
||||
GetInputArgument(state),
|
||||
threads,
|
||||
mapArgs,
|
||||
GetVideoArguments(state),
|
||||
timestampOffsetParam,
|
||||
GetAudioArguments(state),
|
||||
state.SegmentLength.ToString(UsCulture),
|
||||
splitByTimeArg,
|
||||
startNumberParam,
|
||||
state.HlsListSize.ToString(UsCulture),
|
||||
outputPath,
|
||||
toTimeParam
|
||||
outputPath
|
||||
).Trim();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user