added keyframes to progressive streaming
This commit is contained in:
parent
8b9d333608
commit
a59d1f4f70
|
@ -178,9 +178,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
|
|
||||||
var probeSize = Kernel.Instance.FFMpegManager.GetProbeSizeArgument(state.Item);
|
var probeSize = Kernel.Instance.FFMpegManager.GetProbeSizeArgument(state.Item);
|
||||||
|
|
||||||
const string keyFrameArg = " -force_key_frames expr:if(isnan(prev_forced_t),gte(t,0),gte(t,prev_forced_t+5))";
|
return string.Format("{0} {1} -i {2}{3} -threads 0 {4} {5} {6} -f ssegment -segment_list_flags +live -segment_time 10 -segment_list \"{7}\" \"{8}\"",
|
||||||
|
|
||||||
return string.Format("{0} {1} -i {2}{3} -threads 0 {4} {5} {6}{7} -f ssegment -segment_list_flags +live -segment_time 10 -segment_list \"{8}\" \"{9}\"",
|
|
||||||
probeSize,
|
probeSize,
|
||||||
GetFastSeekCommandLineParameter(state.Request),
|
GetFastSeekCommandLineParameter(state.Request),
|
||||||
GetInputArgument(state.Item, state.IsoMount),
|
GetInputArgument(state.Item, state.IsoMount),
|
||||||
|
@ -188,7 +186,6 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
GetMapArgs(state),
|
GetMapArgs(state),
|
||||||
GetVideoArguments(state),
|
GetVideoArguments(state),
|
||||||
GetAudioArguments(state),
|
GetAudioArguments(state),
|
||||||
keyFrameArg,
|
|
||||||
outputPath,
|
outputPath,
|
||||||
segmentOutputPath
|
segmentOutputPath
|
||||||
).Trim();
|
).Trim();
|
||||||
|
|
|
@ -115,7 +115,9 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
return IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf h264_mp4toannexb" : "-codec:v:0 copy";
|
return IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf h264_mp4toannexb" : "-codec:v:0 copy";
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = "-codec:v:0 " + codec + " -preset superfast";
|
const string keyFrameArg = " -force_key_frames expr:if(isnan(prev_forced_t),gte(t,0),gte(t,prev_forced_t+5))";
|
||||||
|
|
||||||
|
var args = "-codec:v:0 " + codec + " -preset superfast" + keyFrameArg;
|
||||||
|
|
||||||
if (state.VideoRequest.VideoBitRate.HasValue)
|
if (state.VideoRequest.VideoBitRate.HasValue)
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,11 +131,18 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
{
|
{
|
||||||
var args = "-vcodec " + videoCodec;
|
var args = "-vcodec " + videoCodec;
|
||||||
|
|
||||||
|
// See if we can save come cpu cycles by avoiding encoding
|
||||||
|
if (videoCodec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return IsH264(state.VideoStream) ? args + " -bsf h264_mp4toannexb" : args;
|
||||||
|
}
|
||||||
|
|
||||||
|
const string keyFrameArg = " -force_key_frames expr:if(isnan(prev_forced_t),gte(t,0),gte(t,prev_forced_t+2))";
|
||||||
|
|
||||||
|
args += keyFrameArg;
|
||||||
|
|
||||||
var request = state.VideoRequest;
|
var request = state.VideoRequest;
|
||||||
|
|
||||||
// If we're encoding video, add additional params
|
|
||||||
if (!videoCodec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
// Add resolution params, if specified
|
// Add resolution params, if specified
|
||||||
if (request.Width.HasValue || request.Height.HasValue || request.MaxHeight.HasValue || request.MaxWidth.HasValue)
|
if (request.Width.HasValue || request.Height.HasValue || request.MaxHeight.HasValue || request.MaxWidth.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -167,13 +174,6 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
args += " -level 3 " + state.VideoRequest.Level;
|
args += " -level 3 " + state.VideoRequest.Level;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
else if (IsH264(state.VideoStream))
|
|
||||||
{
|
|
||||||
// FFmpeg will fail to convert and give h264 bitstream malformated error if it isn't used when converting mp4 to transport stream.
|
|
||||||
args += " -bsf h264_mp4toannexb";
|
|
||||||
}
|
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user