[FFmpeg-user] live transcoding alignment

Nicolas George george at nsup.org
Mon Jul 28 11:08:57 CEST 2014


Le decadi 10 thermidor, an CCXXII, Claudiu Rad a écrit :
> 1. how can i enforce keyframe alignment between output transcoded
> (reencoded) streams in ffmpeg? i don't need P/B or other frame types
> to be aligned, but I-frames should be exactly on the same frame
> numbers on all streams

You could try using the -force_key_frames options, but it is designed for a
few keyframes, not all the keyframes of a stream. For a long video, you
could hit the kernel command line limit or other issues, and for a
continuous stream there is no time limit. Still, have a look.

Or you could force using a constant interval between keyframes, but that
degrades the quality.

Forcing a keyframe on the encoder for the stream #2 based on the decision
made by the encoder for the stream #1 should be rather easy to implement. I
suggest you open a trac ticket tagged as wish/enhancement. Or maybe you can
try your hand implementing it.

> 2. how can i enforce keyframe alignment also with input which i
> would like to simply -c copy ? this means that reencoded outputs
> should have the exactly same keyframe placements as the input, thus,
> internal codec heuristics should be disabled on this matter.

If the stream is not only copied but also decoded (if only to -f null), it
should be as easy to implement as the other option.

> i am talking about a h264/x264 input/output.

If I remember correctly, with x264, forcing too many keyframes have a big
negative impact on the quality, even if the forced keyframes are exactly
those the encoder would have chosen anyway. You should probably look
carefully at the quality and bitrate of your resulting files.

Regards,

-- 
  Nicolas George


More information about the ffmpeg-user mailing list