[Libav-user] Can I skip some packets when decoding

Lucas Soltic lucas.soltic at orange.fr
Tue Dec 9 20:19:44 CET 2014



> Le 9 déc. 2014 à 11:00, Vadim Fedorov <coderiks at gmail.com> a écrit :
> 
> Hi,
> 
> Not really, because your 100th frame depends on the 99th frame (or maybe on 98th), but not directly on the 1st one. However, indirectly it is still depends on the key frame, because 99th depends on 98th and so on. This means that to get your 100th frame you should start from the key frame and decode all 98 frames in between.
> 
> Best regards,
> Vadim 
> 
> 2014-12-09 10:30 GMT+01:00 YIRAN LI <mrfun.china at gmail.com>:
>>> 
>>>> Le 9 déc. 2014 à 08:12, YIRAN LI <mrfun.china at gmail.com> a écrit :
>>>> 
>>>> Hi, 
>>>> 
>>>> I have a question about read frame,
>>>> 
>>>> Suppose I've just opened a file, so the readpointer is at the beginning of the file.
>>>> 
>>>> Compare these two methods:
>>>> 
>>>> 1. call av_read_frame + avcode_decode_video2 to decode 100 video packets( suppose each packet can decode into a frame)
>>>> 2. call av_read_frame, but only decode the 100th packet (all previous 99 packets are just discarded)
>>>> 
>>>> Will the 100th frame from method 1 and the frame from method 2 have same content, timestamp, etc?
>>>> 
>>>> Thanks
>>> 
>>> Hi,
>>> 
>>> Decoding the 100th packet alone can be equivalent in both situations only if this packet is a keyframe. If not, FFmpeg will need all the packets up to the first preceding key frame in order to be able to give you a frame with correct content. I'm unsure whether other metadata like timestamp depend on the method (although I don't think so).
>> 
>> ​Thanks Lucas,
>> 
>> Let's assume both 2 methods start reading from a key packet. and the next key is in the 200th packet.
>> 
>> So you mean continuously decoding to 100th frame has same result as skip 99 and decode 100th alone?

Not sure I got the situation. As soon as you start skipping packets, you are not guaranteed to have correct content until you reach the next key frame. 

>> 
>>>>> Lucas
>>> 
>>> _______________________________________________
>>> Libav-user mailing list
>>> Libav-user at ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/libav-user
>> 
>> 
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/libav-user
> 
> 
> 
> -- 
> С уважением,
> Вадим Фёдоров
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20141209/0969e1f8/attachment.html>


More information about the Libav-user mailing list