undefined reference to `av_register_all‘ 相关问题 FFmpeg被声明为已否决情况

原文链接:FFmpeg被声明为已否决情况整理

在VS2019编译ffmpeg时找不到av_register_all等相关函数定义,网上查了很多都是说extern "C"的问题,但我的extern "C"写得没问题,终于找到了一篇文章能够解决这个问题,转载一下备份。将旧版本相关代码复制为新版本的就可以了。

1、AVStream::codec': 被声明为已否决(类型)
旧版本:
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO){
新版本:
if(pFormatCtx->streams[i]->codecpar->codec_type==AVMEDIA_TYPE_VIDEO){
2、AVStream::codec 被声明为已否决(内容)
旧版本:
pCodecCtx = pFormatCtx->streams[videoIndex]->codec;
新版本:
pCodecCtx = avcodec_alloc_context3(NULL);  
if (pCodecCtx == NULL)  
{  
  printf("Could not allocate AVCodecContext \n");  
  return -1;  
}  
 if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
  printf("Couldn't find audio stream information \n");
  return -1;
}
avcodec_parameters_to_context(pCodecCtx, pFormatCtx->streams[videoIndex]->codecpar);  
3、'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)
4、'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);
5、'avcodec_decode_video2': 被声明为已否决
旧版本:
ret = avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, packet); 
新版本:
if(avcodec_send_packet(pCodecCtx, packet)<0 || (got_picture =avcodec_receive_frame(pCodecCtx, pFrame))<0)       {return -1}
6、' avcodec_alloc_frame': 被声明为已否决
旧版本:
pFrame = avcodec_alloc_frame();
新版本:
pFrame = av_frame_alloc();
7、'av_free_packet': 被声明为已否决
旧版本:
av_free_packet(packet);
新版本:
av_packet_unref(packet);

8、avcodec_decode_audio4:被声明为已否决
旧版本:
int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame, const AVPacket *avpkt);
新版本:
if(avcodec_send_packet(pCodecCtxOut_Video, &pkt)<0 || (got_frame=avcodec_receive_frame(pCodecCtxOut_Video,picture))<0) {return -1}

9、avcodec_encode_video2:被声明为已否决

旧版本:

iif(avcodec_encode_video2(tmpAvCodecCtx, &pkt, picture, &got_picture)<0)

新版本:
if(avcodec_send_frame(tmpAvCodecCtx, picture)<0 || (got_picture=avcodec_receive_packet(tmpAvCodecCtx, &pkt))<0)

10、avcodec_encode_audio2:被声明为已否决

旧版本:

if (avcodec_encode_audio2(tmpAvCodecCtx, &pkt_out, frame, &got_picture) < 0)

新版本:
if(avcodec_send_frame(tmpAvCodecCtx, frame)<0 || (got_picture=avcodec_receive_packet(tmpAvCodecCtx, &pkt_out))<0)

防止原文找不到转载了文章,附上
原文链接:FFmpeg被声明为已否决情况整理_大浪淘沙胡的博客-CSDN博客

  • 4
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值