<div dir="ltr">Hi. <br><br>As many before me, I tried to implement a more strict approach to FrameNum/FrameCount functionality with libav. <br><br>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.<br><br>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 ). <br><br>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?<br><br>Thanks<br><br>Max<br></div>