FFmpeg新版API接口编译报错解决方法

PIX_FMT_YUV420P -> AV_PIX_FMT_YUV420P

'AVStream::codec': 被声明为已否决:

if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO){

=>

if(pFormatCtx->streams[i]->codecpar->codec_type==AVMEDIA_TYPE_VIDEO){

'AVStream::codec': 被声明为已否决:

pCodecCtx = pFormatCtx->streams[videoindex]->codec;

=>

pCodecCtx = avcodec_alloc_context3(NULL);

avcodec_parameters_to_context(pCodecCtx, pFormatCtx->streams[videoindex]->codecpar);

'avpicture_get_size': 被声明为已否决:

avpicture_get_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height)

=>

#include "libavutil/imgutils.h"

av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 1)

'avpicture_fill': 被声明为已否决:

avpicture_fill((AVPicture *)pFrameYUV, out_buffer, AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height);

=>

av_image_fill_arrays(pFrameYUV->data, pFrameYUV->linesize, out_buffer, AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 1);

'avcodec_decode_video2': 被声明为已否决:

ret = avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, packet); //got_picture_ptr Zero if no frame could be decompressed

=>

ret = avcodec_send_packet(pCodecCtx, packet);

got_picture = avcodec_receive_frame(pCodecCtx, pFrame); //got_picture = 0 success, a frame was returned

//注意:got_picture含义相反

'av_free_packet': 被声明为已否决:

av_free_packet(packet);

=>

av_packet_unref(packet);

现在看到的很多FFmpeg讲解实例,其中的代码大多数都是比较老旧的,特别是在一些基本用法上,学习使用时编译会看见很多的warning,类似“ warning: ‘AVStream::codec’ is deprecated (declared at /usr/local/ffmpeg/include/libavformat/avformat.h:880) [-Wdeprecated-declarations] 
out_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;”

本篇博客意在整理自己在实际使用中,对这些新老对照API的整理,以方便后续使用,本身也会持续更新。


  • avcodec_decode_video2() 
    原本的解码函数被拆解为两个函数avcodec_send_packet()和avcodec_receive_frame() 具体用法如下:
   old:avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, pPacket);new:avcodec_send_packet(pCodecCtx, pPacket);avcodec_receive_frame(pCodecCtx, pFrame);
  • 1
  • 2
  • 3
  • 4
  • 5
  • avcodec_encode_video2() 
    对应的编码函数也被拆分为两个函数avcodec_send_frame()和avcodec_receive_packet() 具体用法如下:
   old:avcodec_encode_video2(pCodecCtx, pPacket, pFrame, &got_picture);new:avcodec_send_frame(pCodecCtx, pFrame);avcodec_receive_packet(pCodecCtx, pPacket);
  • 1
  • 2
  • 3
  • 4
  • 5
  • avpicture_get_size() 
    现在改为使用av_image_get_size() 具体用法如下:
   old:avpicture_get_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height);new://最后一个参数align这里是置1的,具体看情况是否需要置1av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 1);
  • 1
  • 2
  • 3
  • 4
  • 5
  • avpicture_fill() 
    现在改为使用av_image_fill_arrays 具体用法如下:
   old:avpicture_fill((AVPicture *)pFrame, buffer, AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height);new://最后一个参数align这里是置1的,具体看情况是否需要置1av_image_fill_arrays(pFrame->data, pFrame->linesize, buffer, AV_PIX_FMT_YUV420P,  pCodecCtx->width, pCodecCtx->height,1);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 关于codec问题有的可以直接改为codecpar,但有的时候这样这样是不对的,所以我也还在探索,这里记录一个对pCodecCtx和pCodec赋值方式的改变
   old:pCodecCtx = pFormatCtx->streams[video_index]->codec;pCodec = avcodec_find_decoder(pFormatCtx->streams[video_index]->codec->codec_id);new:pCodecCtx = avcodec_alloc_context3(NULL);avcodec_parameters_to_context(pCodecCtx,pFormatCtx->streams[video_index]->codecpar);pCodec    = avcodec_find_decoder(pCodecCtx->codec_id);

来源: https://www.isvee.com/archives/2018

被声明为已否决 解决方法相关推荐

  1. Tips:error C4996: 'GetVersionExA': 被声明为已否决

    问题描述: 调用GetVersionEx获取系统版本报错. error C4996: 'GetVersionExA': 被声明为已否决 解决方法: 1. #pragma warning(disable ...

  2. errorC4996: 'AVStream::codec': 被声明为已否决

    错误信息: errorC4996: 'AVStream::codec': 被声明为已否决 解决方法:

  3. ffmpeg avstream::codec 被声明为已否决

    ffmpeg avstream::codec 被声明为已否决 之前的版本 pCodecCtx = pFormatCtx->streams[videoIndex]->codec; 之后的版本 ...

  4. error C4996 ‘pugixml_documentload‘ 被声明为已否决的解决方法

    Gbd28181Device.cpp(550,18): error C4996: 'pugi::xml_document::load': 被声明为已否决 对于上面的问题,我找到以下三种解决方法: 方法 ...

  5. VS使用FFmpeg被声明为已否决的解决方案

    原因 FFmpeg中所谓的"被声明为已否决"就是因为函数或者结构体属性被标示为attribute_deprecated,很有可能在未来的版本中就删除了. 解决方法 所以我们最好的解 ...

  6. 'avpicture_fill': 被声明为已否决

    'avpicture_fill': 被声明为已否决 尝试这个 1.Project Properties > Configuration Properties > C/C++ > Ge ...

  7. FFmpeg —— “被声明为已否决” - 集合

    说明      这里暂且记录本人在FFmpeg开发过程中遇到的"被声明为已否决"的一部分集合.有可能记录不全,但后面若是碰到类似情况,会继续更新的.      另外,为什么会出现这 ...

  8. ffmpeg--被声明为已否决

    4.1版本弃用清单 ffmpeg API里面有各种接口改变的记录,如果发现接口不能用了,可以去搜索文档,可以找到对应的新接口,然后到新接口对应的头文件中找到说明文字. 常见的替换的API 1) 不认识 ...

  9. error C4996: ‘GetVersionExW‘: 被声明为已否决

    最近做的一个MFC项目中使用到了BtnST的第三方组件,由于使用的BtnST源代码比较旧,在用visual studio 2017 编译的时候,把原本支持Xp的功能去掉,重新编译马上就提示 BCMen ...

最新文章

  1. ZedGraph在Web中的使用
  2. 会员日亚马逊工人罢工:反抗“与机器比速度”的考核制!
  3. Java关键字final、static、this、super使用总结
  4. js 计算任意凸多边形内最大矩形_题库 | 计算机视觉常见面试题型介绍及解答 第 7 期...
  5. [安全模型][Cambria Math][A][]敌手A-> 怎么打出来?
  6. JS组件系列——封装自己的JS组件
  7. 【鲲鹏来了】手把手教你在鲲鹏上使用编程语言——Java、Python
  8. java一次性查询几十万,几百万数据解决办法
  9. c语言程序设计对称数,c语言程序设计--对称数
  10. Python入门经典学习1-乳腺癌分类问题
  11. 【maya】模型学习
  12. 华佗穿越来教程序员睡觉
  13. 所选的用户密钥未在远程主机上注册,请再试一次
  14. OpenCV之光流法运动目标跟踪
  15. 数字化时代:企业数字化转型实践路径
  16. 日渐临近的苹果秋季发布会,iOS 11 GM 固件到底提前泄露了哪些秘密?
  17. 【笔记】reko 0.10.2 反编译工具安装和使用记录|(2) 翻译 user‘s guide
  18. 阿里云Mysql5.7 数据库恢复 qp.xb文件恢复数据
  19. 与时俱进版前端资源教程
  20. 【AD20学习笔记】PCB设计规则设置及手工布线

热门文章

  1. matlab 向量去除空格,MATLAB向量
  2. 内核变量——Jiffies
  3. 函数调用oracle,oracle 函数调用
  4. 打孔怎么定位_红米K40将要发布,采用居中打孔屏,极窄边框设计
  5. Linux监听请求到达时间,4: zabbix5.0自动发现网站域名并监控访问状态和请求时间...
  6. golang mysql单元测试_golang test测试使用
  7. html 图片自动切换插件,jquery图片切换插件
  8. Windows 11,一个新功能,一场新屠杀!
  9. 你以为在做的是微服务?不!你只是做了个比单体还糟糕的分布式单体!
  10. 百度搜出十年前的照片?法院判赔1元~