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???
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.