FFmpeg报错被声明为已否决问题

	for (int i = 0; i < ac->nb_streams; i++)
	{
		AVStream *in_stream = ac->streams[i];

		//TRACE("codec id: %d, \n", in_stream->codec->codec_id);

		if (in_stream->codec->codec_type == AVMEDIA_TYPE_VIDEO)		
		{			
			m_coded_width = in_stream->codec->width;
			m_coded_height = in_stream->codec->height;

			if (in_stream->codec->codec_id == AV_CODEC_ID_H264)
			{
			}
		}
	}	

使用AVStream::codec成员时,简单的获取分辨率,最终编译报错:

1>e:\vs2013test\opencvtest\opencvtest\myffmpeg.cpp(52): error C4996: 'AVStream::codec': 被声明为已否决
1>          e:\vs2013test\public_ft\public\include\libavformat\avformat.h(885) : 参见“AVStream::codec”的声明
1>e:\vs2013test\opencvtest\opencvtest\myffmpeg.cpp(54): error C4996: 'AVStream::codec': 被声明为已否决
1>          e:\vs2013test\public_ft\public\include\libavformat\avformat.h(885) : 参见“AVStream::codec”的声明
1>e:\vs2013test\opencvtest\opencvtest\myffmpeg.cpp(55): error C4996: 'AVStream::codec': 被声明为已否决
1>          e:\vs2013test\public_ft\public\include\libavformat\avformat.h(885) : 参见“AVStream::codec”的声明
1>e:\vs2013test\opencvtest\opencvtest\myffmpeg.cpp(57): error C4996: 'AVStream::codec': 被声明为已否决
1>          e:\vs2013test\public_ft\public\include\libavformat\avformat.h(885) : 参见“AVStream::codec”的声明

在知识的海洋中翱翔后得出:

将此处的"是"修改成"否"。

1>e:\vs2013test\opencvtest\opencvtest\myffmpeg.cpp(52): warning C4996: 'AVStream::codec': 被声明为已否决
1>          e:\vs2013test\public_ft\public\include\libavformat\avformat.h(885) : 参见“AVStream::codec”的声明
1>e:\vs2013test\opencvtest\opencvtest\myffmpeg.cpp(54): warning C4996: 'AVStream::codec': 被声明为已否决
1>          e:\vs2013test\public_ft\public\include\libavformat\avformat.h(885) : 参见“AVStream::codec”的声明
1>e:\vs2013test\opencvtest\opencvtest\myffmpeg.cpp(55): warning C4996: 'AVStream::codec': 被声明为已否决
1>          e:\vs2013test\public_ft\public\include\libavformat\avformat.h(885) : 参见“AVStream::codec”的声明
1>e:\vs2013test\opencvtest\opencvtest\myffmpeg.cpp(57): warning C4996: 'AVStream::codec': 被声明为已否决
1>          e:\vs2013test\public_ft\public\include\libavformat\avformat.h(885) : 参见“AVStream::codec”的声明

再次编译,错误变成警告。

本想就此过去,但想了解一下,发现可以用AVCodecParameters代替AVCodecContext。

修改后:

for (int i = 0; i < ac->nb_streams; i++)
	{
		AVStream *in_stream = ac->streams[i];

		//TRACE("codec id: %d, \n", in_stream->codec->codec_id);

		if (in_stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
		{			
			m_coded_width = in_stream->codecpar->width;
			m_coded_height = in_stream->codecpar->height;

			if (in_stream->codecpar->codec_id == AV_CODEC_ID_H264)
			{
			}
		}
	}	

编译通过。 

 

初入坑,请大家多多指教,共同学习!

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值