ffmpeg开发中出现的问题(二)

来源:互联网 发布:时间序列预测值算法 编辑:程序博客网 时间:2024/05/17 09:34

接上

5. sws_scale()函数可以转格式和大小
当frame转frame时,要用avpicture_fill()分配dst_frame的大小和格式
avpicture_fill()中的buff需要另外分配,

int num = avpicture_get_size(PIX_FMT_YUV420P, width, height);
uint8_t *buffer = (uint8_t*)av_malloc(num*sizeof(uint8_t));
avpicture_fill((AVPicture *)oFrame, buffer, PIX_FMT_YUV420P, width, height);

而oFrame = avcodec_alloc_frame();是不分配里面的data, linesize数据区的
解码时,avcodec_decode_video2();这里面的AVFrame是分配的

6. 源代码是解决问题的根本

原创粉丝点击