[英]FFmpeg AVPacket control
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.根据 avcodec.h 文件中的文本,有些解码器可能支持一个
AVPacket
中的多个帧,但avcodec_decode_video2
方法只解码第一帧......我必须得到所有这些。
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???在 libavcodec 的源代码中,参数 AVPacket 被注意到为
const AVPacket *avpacket
,所以在解码这个数据包解码器时不能改变 AVPacket 的字段,我可以改变数据包数据的偏移量或删除已经接收的数据以使解码器读取循环中的所有帧包???
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.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.