[Libav-user] How to get some packet information before decoding

Carl Eugen Hoyos ceffmpeg at gmail.com
Sat Apr 18 18:09:24 EEST 2020

Am Sa., 18. Apr. 2020 um 16:52 Uhr schrieb Mohammed Bey Ahmed
Khernache <mohbeyinfo at gmail.com>:

> could someone tell me how to get:
>     1- the total number of packets that a video bit-stream contain?

At least theoretically, containers exist that provide this information,
but in general, it is unavailable (and unreliable).

>     2- the packet type (I, P, or B)?

The parser should tell you (if FFmpeg provides a parser for
the video format).

> Actually, I need to have these information before to start decoding of packets.

The parser also allows you to read the whole stream (without actual
decoding) and know the number of frames in it. While this is less
work than decoding the stream, it is of course not free if done in

Carl Eugen

More information about the Libav-user mailing list