Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg: make a copy from a decoded frame (AVFrame)

I want to make a backup frame (AVFrame) from a special frame(let's say pic). So, I have written

 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;

to copy pic to bkf. But after running, I saw a lot of distortion. any idea how to make a correct copy from a decoded frame?

like image 857
Mehdi Avatar asked Nov 19 '25 14:11

Mehdi


1 Answers

Use av_frame_copy(bkf, pic) after allocating bkf with AVFrame *bkf = av_frame_alloc().

like image 59
Ronald S. Bultje Avatar answered Nov 22 '25 04:11

Ronald S. Bultje



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!