[libav-api] Encoding video with non-fixed FPS

Luca Barbato lu_zero at gentoo.org
Thu Dec 29 17:04:34 CET 2011

On 29/12/11 15:57, Soren Dreijer wrote:
>> Depends on your container. You might not want to use the default frame
>> interleaver in some cases.
> I'm currently using the MJPEG codec and plan on just doing raw PCM.
> Will the default interleaver be good enough, you think?

Those are codecs, not container formats.

>> you decide the timebase and put the time reference in timebase units, that
>> means that if the timebase is 1/1000 s and your frame is around 1/25 s, your
>> pts would be about 40 timebase unit apart each other.
> So, rather than setting the timebase to 1/<fps>  as e.g.
> output-example.c does, I'd simply set it to 1/1000 if my incoming
> timestamps are in milliseconds? Let's say I capture my first frame a 0
> ms and the second frame a 45 ms. Should I then set the frames' pts to
> 0 and 45, respectively in the AVPacket?

should work.

>> the encoder does not care about timing. It process frames as they go.
> Since I'm capturing the frames live, the source might have a hiccup
> and I might skip a frame (or several). Since the encoder only cares
> about the frames I tell it, I need to be able to tell it that there
> was a gap somewhere. I was planning on doing that by just feeding it
> the previous frame for the number of frames I knew I dropped, but I'm
> curious if the encoder does that automatically if it notices a gap in
> the pts.

The encoder does not care about pts, the muxer will and depending on it 
you might have to use such tricks.



Luca Barbato

More information about the libav-api mailing list