ffmpeg:从解码帧(AVFrame)制作副本

时间:2015-08-18 21:59:29

标签: ffmpeg h.264 video-processing

我想从一个特殊的帧(比如说 pic )制作备份帧(AVFrame)。所以,我写了

 AVFrame* bkf = avcodec_alloc_frame();
 memcpy(bkf,pic,sizeof(AVFrame));
 bkf->extended_data = pic->extended_data;
 bkf->linesize[0]   = pic->linesize[0];
 memcpy(bkf->data, pic->data, sizeof(pic->data));
 bkf->reordered_opaque = pic->reordered_opaque;
 bkf->sample_rate    = pic->sample_rate;
 bkf->channel_layout = pic->channel_layout;
 bkf->pkt_pts = pic->pkt_pts;
 bkf->pkt_pos = pic->pkt_pos;
 bkf->width = pic->width;
 bkf->format =  pic ->format;

pic 复制到 bkf 。但跑完后,我看到了很多失真。知道如何从解码的帧中制作正确的副本吗?

1 个答案:

答案 0 :(得分:7)

使用AVFrame * bkf = av_frame_copy()分配bkf后,使用av_frame_alloc(bkf,pic)。