下面以win64环境为例:
-
1.下载FFmpeg
地址:https://ffmpeg.zeranoe.com/builds/
注意事项:Linking 下拉列表提供了3种下载,分别为Static Shared Dev .都下载下来到本地去,相关介绍自行百度
-
2.下载配置clion
File->Settings:搜索 Toolchains配置项,去配置MinGW
注意事项:先查看clion是否64位,配置MinGW要与之对应,否则在编译项目时会出现一些奇怪错误,如 undefined reference to XXX
-
3.搭建FFmpeg开发环境
1.clion新建c++空项目,名称:TestFfmpeg
2.修改CMakeLists.txt 文件内容如下:
cmake_minimum_required(VERSION 3.15)
project(TestFfmpeg)
set(CMAKE_CXX_STANDARD 14)
include_directories(D:\FFmpeg\init\ffmpeg-4.2.2-win64-dev\ffmpeg-4.2.2-win64-dev\include)
link_directories(D:\FFmpeg\init\ffmpeg-4.2.2-win64-dev\ffmpeg-4.2.2-win64-dev\lib)
add_executable(TestFfmpeg main.cpp)
target_link_libraries(TestFfmpeg avfilter avformat avcodec avutil swscale avdevice)
-
4.验证
运行main.cpp,得到正确输出,内容如下:
#include extern "C" {#include "libavcodec/avcodec.h"#include "libavformat/avformat.h"#include "libavutil/time.h"#include "libswscale/swscale.h"#include
}int main() {std::cout << avformat_configuration();return 0;
}