<div>Suppose the frames are like this(in order of pts): I BBB P BBB P [B]BB P</div><div>Now I want to skip to [B] as fast as possible.</div><div>There is one I frame and two P frames required to be put into the decoder.</div><div>How to skip the 6 B frames before [B]?</div><div>What I have tried, is to check the packets to see whether they are useless. Once I find it is the packet of a B frame, I have 2 choices.</div><div>1)free the packet and go to read a packet from av_read_frame to continue the loop</div><div>2)free the packet and put it into the "avcodec_decode_video2", try to get a frame. And then , continue the loop</div><div><br></div><div>These two both don't work well. The target frame [B] I got is destroyed.</div><div><br></div><div>The way I check whether the packet is of a B frame is like this:</div><div>There is a "last_pframe" to declare the pts of the last P(or I) frame which has been put into the "<span style="line-height: 1.5;">avcodec_decode_video2</span><span style="line-height: 1.5;">". Get a packet, and check if packet.pts>last_pframe. If it is true, it is a packet from a new P frame. Else, it is a B frame and consider to skip it. Because a P frame is always followed by the B frames in the order of dts. For an experimental video with 25 frames, the judgement is as what I want. </span></div><div><br></div><div>How to skip some useless B frames in the right way?</div><div><br></div><div><includetail><!--<![endif]--></includetail></div>