[Libav-user] Reliably getting the current frame number

coordz at megaroms.co.uk coordz at megaroms.co.uk
Fri Jan 23 18:10:52 CET 2015


Hi all,

I'm having some problems just doing a simple thing: getting the current
frame number from a decoded AVFrame. I tried a few things (starting from
the most obvious) but I couldn't find one that consistently works:

1) Look at AVFrame.display_picture_number. Sadly, this seems to be zero
for all the files I've decoded.

2) Look at AVFrame.display_picture_number. This seems to count
sequentially from zero for most files (e.g. MP4) but stays at zero for
others (e.g. LAGS). (Aside: it also makes me wonder if the h264 is
reordering frames for me.)

3) Use av_frame_get_best_effort_timestamp(frame) to get frame timestamp.
This field always appears to be set but to convert it to a frame number I
need to know the average display time of a frame. Sadly
AVStream.avg_frame_rate is often zero.

4) Look at AVFrame.pts. Seems to stay stuck at zero for many files and I
still can't convert it similar to 3.

So, is it possible to get the current frame number reliably?

(Background: I'm getting skipped frames when decoding a lagarith (LAGS)
video. I'm trying to detect when a frame has been skipped which
(hopefully) will give me a clue to why a frame is skipped.)

Thanks.




More information about the Libav-user mailing list