added keyframes to progressive streaming

pull/702/head
Luke Pulverenti 12 years ago
parent 8b9d333608
commit a59d1f4f70

@ -178,9 +178,7 @@ namespace MediaBrowser.Api.Playback.Hls
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}{7} -f ssegment -segment_list_flags +live -segment_time 10 -segment_list \"{8}\" \"{9}\"",
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}\"",
probeSize,
GetFastSeekCommandLineParameter(state.Request),
GetInputArgument(state.Item, state.IsoMount),
@ -188,7 +186,6 @@ namespace MediaBrowser.Api.Playback.Hls
GetMapArgs(state),
GetVideoArguments(state),
GetAudioArguments(state),
keyFrameArg,
outputPath,
segmentOutputPath
).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";
}
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)
{

@ -131,47 +131,47 @@ namespace MediaBrowser.Api.Playback.Progressive
{
var args = "-vcodec " + videoCodec;
var request = state.VideoRequest;
// If we're encoding video, add additional params
if (!videoCodec.Equals("copy", StringComparison.OrdinalIgnoreCase))
// See if we can save come cpu cycles by avoiding encoding
if (videoCodec.Equals("copy", StringComparison.OrdinalIgnoreCase))
{
// Add resolution params, if specified
if (request.Width.HasValue || request.Height.HasValue || request.MaxHeight.HasValue || request.MaxWidth.HasValue)
{
args += GetOutputSizeParam(state, videoCodec);
}
return IsH264(state.VideoStream) ? args + " -bsf h264_mp4toannexb" : args;
}
if (request.Framerate.HasValue)
{
args += string.Format(" -r {0}", request.Framerate.Value);
}
const string keyFrameArg = " -force_key_frames expr:if(isnan(prev_forced_t),gte(t,0),gte(t,prev_forced_t+2))";
// Add the audio bitrate
var qualityParam = GetVideoQualityParam(request, videoCodec);
args += keyFrameArg;
if (!string.IsNullOrEmpty(qualityParam))
{
args += " " + qualityParam;
}
var request = state.VideoRequest;
// Add resolution params, if specified
if (request.Width.HasValue || request.Height.HasValue || request.MaxHeight.HasValue || request.MaxWidth.HasValue)
{
args += GetOutputSizeParam(state, videoCodec);
}
args += " -vsync vfr";
if (request.Framerate.HasValue)
{
args += string.Format(" -r {0}", request.Framerate.Value);
}
if (!string.IsNullOrEmpty(state.VideoRequest.Profile))
{
args += " -profile:v " + state.VideoRequest.Profile;
}
// Add the audio bitrate
var qualityParam = GetVideoQualityParam(request, videoCodec);
if (!string.IsNullOrEmpty(state.VideoRequest.Level))
{
args += " -level 3 " + state.VideoRequest.Level;
}
if (!string.IsNullOrEmpty(qualityParam))
{
args += " " + qualityParam;
}
args += " -vsync vfr";
if (!string.IsNullOrEmpty(state.VideoRequest.Profile))
{
args += " -profile:v " + state.VideoRequest.Profile;
}
else if (IsH264(state.VideoStream))
if (!string.IsNullOrEmpty(state.VideoRequest.Level))
{
// 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";
args += " -level 3 " + state.VideoRequest.Level;
}
return args;

Loading…
Cancel
Save