[FFmpeg-user] frame number question

Mark Filipak (ffmpeg) markfilipak at bog.us
Sun Dec 20 22:54:12 EET 2020

On 12/20/2020 01:49 PM, Paul B Mahol wrote:
> On Sun, Dec 20, 2020 at 12:03 AM Mark Filipak (ffmpeg) <markfilipak at bog.us>
> wrote:
>> For the developers:
>> At what point are frame numbers assigned?
> Libavfilter does not really care about frame numbers much.
> It internally just count number of frames that get into filter and number
> of frames that get out filter.
>> I would guess: When they leave the decoder. Am I right?
> Decoder also does not care of frame numbers.
>> Example:
>> If '-vf decimate' removes frame[(n+1)%5==2], are frames renumbered at that
>> point or are the frames
>> left as frame[0], frame[2], frame[3], frame[4], frame[5], frame[7],
>> frame[8], frame[9], etc.
>> If you prefer I discover this on my own, that's okay, but I don't know how
>> to put the frame number
>> (as text) into the frames so that when I frame-step through the video I
>> can see the frame numbers.
>> If you could help with that, I'm pretty sure I can take the rest of the
>> needed steps on my own.
> As mentioned above, each filter counts frame numbers from 0, and the frames
> that goes out of filter are also starting from 0.
> There are no gaps.

Ah! So, frame number, i.e. 'n' or %{n}, is a dynamically assigned number (starting with '0') that's 
reassigned, frame-by-frame, by each element of a filter chain.

> Each frame that is decoded/filtered have no count number assigned to them
> at all.
Understood: That frame number is not actually part of the video stream (TS or PS). I think that's 
what you meant.

Thanks, Paul. The information you supplied would make a good addition to the documentation.

More information about the ffmpeg-user mailing list