[libav-api] Decoding Packets, missing Frames at End

Anton Khirnov anton at khirnov.net
Wed Feb 6 19:06:01 CET 2013


On Tue, 5 Feb 2013 11:05:22 +0100, Ronny Wegener <max_schmerz at gmx.net> wrote:
> Hi,
> 
> i'm running a simple while loop, reading all video packets, decode the
> corresponding frames and print the timestamps.
> 
> The first frame is successfully decoded after reading the fifth
> packet. So the while loop stops after reading the last packet, before
> i decoded all frames:
> 
> [OUTPUT]
>   packet.pts=0 => GOT NO PICTURE
>   packet.pts=1 => GOT NO PICTURE
>   packet.pts=2 => GOT NO PICTURE
>   packet.pts=3 => GOT NO PICTURE
>   packet.pts=4 => frame.pts=0
>   packet.pts=5 => frame.pts=1
>   packet.pts=6 => frame.pts=2
>   packet.pts=7 => frame.pts=3
>   packet.pts=8 => frame.pts=4
>   packet.pts=9 => frame.pts=5
> [END]
> 
> It seems the packets are buffered, how can i decode the last frames
> from the internal buffered packets?
> 

As described in the documentation [1], to flush the decoder you must call
avcodec_decode_x with empty AVPackets, i.e.  data = NULL and size = 0

[1] http://libav.org/doxygen/master/group__lavc__decoding.html#ga3e4048fd6893d4a001bdaa3d251f3c03

-- 
Anton Khirnov


More information about the libav-api mailing list