[FFmpeg-user] How to get he total number of frames

Peter White peter.white at posteo.net
Tue Mar 9 14:55:29 EET 2021

On Tue, Mar 09, 2021 at 01:41:38PM +0100, Nicolas George wrote:
> Peter White (12021-03-09):
> > Is there a meaningful difference in this context?
> The fact that you need to ask is proof enough that it is needed.

I understand that a packet is what the demuxer sends to the decoder
which in turn decodes it into a frame. But decoding is not necessary if
I only want the *number* of frames not their content. Hence the question
if *in this context* there is a difference.
If I need to decode a frame to count it, then the counting operation is
not feasible.

> > Now we are getting somewhere. No, I have not, because I did not know it
> > can do that. But above question remains: does packet count always equal
> > frame count? What might be pitfalls with this approach?
> The frame count could be different than the packet count with some
> codecs, indeed, but I am not aware of any specific case.

I had a suspicion that might be. Would you agree that in the vast
majority of cases it is safe to assume frame count equals packet count?

> Anyway, using -c copy gives the same result.

Not quite, see my other message, please.


More information about the ffmpeg-user mailing list