前言
本文参考雷霄骅的博文最简单的基于FFMPEG的Helloworld程序,使用c++根据ffmpeg-4.1版本改写(原文代码基于旧版本ffmpeg)。代码见下文。
本文代码地址见https://github.com/2997215859/ffplay-learn/blob/master/Video/print_info.cpp
本文代码基于ffmpeg-4.1版本,事先需要安装好ffmpeg
本文代码提供CMakeLists.txt,见附录CMakeLists.txt部分,或根据CMakeLists.txt改写。需要链接的库如下(基本上安装ffmpeg、ffplay、SDL2之后就有了)。
avdevice avfilter avformat avcodec swscale swresample postproc avutil m xcb xcb-shm xcb xcb-shape xcb xcb-xfixes xcb-render xcb-shape xcb asound pthread m fontconfig freetype freetype z bz2 lzma SDL2 SDL2main
代码
主函数
int main () {
cout << "\n<<Configuration>>\n" << configurationInfo(); // 打印ffmpeg的configure信息
cout << "\n<<URLProtocol>>\n" << urlProtocolInfo(); // 打印URL
cout << "\n<AVFormat>\n" << formationInfo();
cout << "\n<<AVCodec>>\n" << avcodecInfo();
cout << "\n<<AVFilter>>\n" << avfilterInfo();
return 0;
}
分函数
1. 打印ffempg的configure信息,直接调用avdevice_configuration函数,返回char字符串
string configurationInfo () {
return string(avdevice_configuration());
}2. 利用avio_enum_p