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)
{
}
}
}
编译通过。
初入坑,请大家多多指教,共同学习!