[Libav-user] What is the correct way to read frames

Oleg mybrokenbeat at gmail.com
Sun Mar 24 15:37:53 CET 2013


There can be more than 1 frame per packet and your code assuming that there is only 1 frame per packet.
You should do smth like that:

AVPacket tmp_pkt;
int size;

....

tmp_pkt.data = pkt.data;
tmp_pkt.size = pkt.size;

while ( (size = avcodec_decode_video2(ctx,frame,&got_pict,&tmp_pkt) ) > 0)
{
	store_decoded_frame(frame);
	tmp_pkt.data += size;
	tmp_pkt.size -=  size;
}


24.03.2013, в 16:23, Pauli Suuraho написал(а):

> Hello all.
> 
> I'm a newcomer to use ffmpeg, and I've been bugging my mind about this one thing.
> 
> I have videoclips (either h264 or prores), and I want to extract all the frames. I'm using 32 bit ffmpeg-20130322-git-e0e8c20-win32 zeranoe shared+dev and Qt compiled using MSVC2010.
> 
> I'm using the following code to extract the frames.
> 
> http://pastebin.com/DrC9H6g0
> 
> If I have a test clip that is 30 frames, 30fps long, for some reason the lib always extracts only 24 frames and then says end of file.
> 
> FFmpeg.exe extracts all the frames (for example to PNGs) correctly. So clearly I'm doing something wrong.
> 
> This happens with every clip I have. I've even tried to repack the clips with ffmpeg but the output is same: last frames won't get noticed.
> 
> I guess this has something to do with I,P,B-frames, but not sure how.
> 
> Any help is appreciated!
> 
> Thanks,
> Pauli
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130324/10e24d11/attachment.html>


More information about the Libav-user mailing list