FFmpeg AVPacket control

Go To StackoverFlow.com

1

According to the text in avcodec.h file, there are some decoders may support multiple frames in one AVPacket, but avcodec_decode_video2 method decode only first frame... I must get all of them.

In source code of libavcodec, parameter AVPacket noticed as const AVPacket *avpacket, so while decoding this packet decoder cant change AVPacket's fields, can I change maybe an offset of packet data or delete already recived data for making decoder read in loop all frames in the packet???

2012-04-04 16:53
by mmmaaak


1

I don't think that can even happen anymore, but basically you would do something like this:

while(packet->size > 0)
{
     int ret = avcodec_decode_video2(..., packet);
     if(ret < -1)
        throw std::exception("error");

     packet->size -= ret;
     packet->data += ret;
}

// NOTE! You have to restore original packet->size and packet->data, or modify a copy, before calling av_packet_free.
2012-04-04 17:12
by ronag
Ads