[Libav-user] Encoding Variable Frame Rate with libffmpeg

Raymond Blum raygeeknyc at gmail.com
Wed May 7 16:46:49 CEST 2014


Hi all
  I've read some threads on this list and the dranger tutorials - I think
that I am setting up VFR as "correctly" as I can but I still don't see it
reflected in playback so I am writing here.

1) I'm capturing and preprocessing frames at a highly variable rate - from
7 to 33 FPS
2) I chose to encode them with a time_base of 1/25
3) I am encoding them using mpeg1: const int codec_id =
AV_CODEC_ID_MPEG1VIDEO;
4) I set the encoded frame's PTS to an increasing integer value that I
calculate using (elapsed seconds / 25) - so I am always setting PTS to the
closest frame number for this point in time at the desired frame rate.  If
the "effective" frame rate is greater than 25, I skip the frame. So for
example, if I am actually capturing and processing at 12 FPS, my pts values
are 1,3,5,7...
5) I encode the packet and observe that the packets DTS and PTS are
actually [i-2] and [i-1] respectively where i is the pts I set for this
frame.  So a frame for which I set a PTS of 7 encodes a packet with dts of
3 and pts of 5.
6) When I use ffplay to read back the file, it plays at 25 FPS, seemingly
ignoring the PTS I have written.

I've gathered that variable frame rate is highly dependent on the codec,
format and player used.  I've also seen posts on this list that say that
the poster has gotten this technique to work.

What I am hoping for is an example of this (encoding a VFR) working or a
pointer to which codec and/or parameters for the encoding *do* support this.

TIA
---Raymond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140507/ac052743/attachment.html>


More information about the Libav-user mailing list