rav1e icon indicating copy to clipboard operation
rav1e copied to clipboard

Add support for variable framerate encodings

Open sdroege opened this issue 2 months ago • 1 comments

Describe the bug

Currently rav1e assumes that every frame's duration is one unit of time_base. This is only correct for fixed framerate streams.

To Reproduce

Using rav1e to encode a stream coming from a normal webcam or some other source with a variable framerate causes rate control to not work correctly.

Expected behavior

It should be possible to provide timestamps for each frame (in time_base units) and this would be used by rate control to figure out how much time each frame represents.

Prior art can be found in aom (aom_codec_encode() PTS and duration parameters) or libvpx (vpx_codec_encode() PTS and duration parameters). Both seem to work correctly if the duration is just an estimate (you don't necessarily know it yet without waiting for the next frame) and use the PTS as main source of truth.

sdroege avatar May 22 '24 06:05 sdroege