[Libav-user] Is it possible to detect unused/invalid packets (without decoding)

Max Vlasov max.vlasov at gmail.com
Wed Jan 28 12:45:55 CET 2015


Hi.

As many before me, I tried to implement a more strict approach to
FrameNum/FrameCount functionality with libav.

The idea was to read all packets saving pts and keyframe flag (without
decoding) and make a list of them in order of ptses. After this we have a
ready FrameCount and when one needs to jump to an exact frame number, the
way to go is to search inside this array for closest keyframe packet
before, seek and read packets (also without decoding) until earliest
keyframe before the one and then read AND decode until the desired frame.

This approach has some limitations (time for example usually proportional
to the I/O reading speed), but apart from this, many videos behaves well.
But some not and they probably have a case of unused/invalid packets. I
think so because the logic above assumes every pts is visited by decoder
when it produces frames. If some packets are not used then we expect the
frame num 123 to have timestamp (time1), but in reality since some packets
are not used the frame 123 (as decoder produces them) has timestamp (time1
+ something ).

When I looked at real examples of videos with problems, I noticed that
there were packets with very small sizes like 7 bytes or something. I
suspect them to be invalid, but I can not rely only on the size in order to
make such assumptions. Is there more reliable way to see that a packet is
not used/invalid?

Thanks

Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20150128/182d7209/attachment.html>


More information about the Libav-user mailing list