[Libav-user] What is the correct way to read frames
Pauli Suuraho
pauli.suuraho at gmail.com
Sun Mar 24 15:58:26 CET 2013
I changed the code to the following
while(av_read_frame(pFormatCtx, &packet) >= 0)
{
avcodec_get_frame_defaults(pFrame);
int frameFinished;
if(packet.stream_index==i)
{
// Is this a packet from the video stream -> decode video
frame
ffmpeg::AVPacket tmp_pkt;
tmp_pkt.data = packet.data;
tmp_pkt.size = packet.size;
qint64 size = 0;
while ( (size =
avcodec_decode_video2(pCodecCtx,pFrame,&frameFinished,&tmp_pkt) ) > 0)
{
if(frameFinished)
{
qDebug() << "Codec reported frame number to be " <<
pCodecCtx->frame_number;
}
tmp_pkt.data += size;
tmp_pkt.size -= size;
}
}
av_free_packet(&packet); // Free the packet that was
allocated by av_read_frame
}
Now I get 30 times error [h264 @ 000ff140] no picture, and frameFinished = 0
-Pauli
On 24 March 2013 16:37, Oleg <mybrokenbeat at gmail.com> wrote:
> 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
>
>
>
> _______________________________________________
> 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/7ef7eae0/attachment.html>
More information about the Libav-user
mailing list