概述
下载 FFmpeg build
搭建环境
- 新建文件夹 FFMPEGSDK, 将 dev 中的 include 和 lib, shared 中的 dll 都拷贝过来.
- 将 FFMPEGSDK 文件夹拷贝到你平时放置 SDK 的位置. eg: E:/FFMPEGSDK. 设置环境变量
FFMPEGDIR
, 并指定该路径. - 新建一个工程. 配置该工程:
- 头文件检索目录: C/C++-常规-附加包含目录 增加:
$(FFMPEGDIR)\include
- 链接:
- 链接器-常规-附加库目录 增加:
$(FFMPEGDIR)\lib
- 链接器-输入-附加依赖性 增加:
$(FFMPEGDIR)\lib\avcodec.lib;$(FFMPEGDIR)\lib\avformat.lib;$(FFMPEGDIR)\lib\avutil.lib;$(FFMPEGDIR)\lib\avdevice.lib;$(FFMPEGDIR)\lib\avfilter.lib;$(FFMPEGDIR)\lib\postproc.lib;$(FFMPEGDIR)\lib\swresample.lib;$(FFMPEGDIR)\lib\swscale.lib;
- 运行时动态加载: 将各 DLL 复制到exe同级目录.
- 修改 main.cpp
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
#include <libavutil/opt.h>
#include <libavutil/mathematics.h>
#include <libavutil/samplefmt.h>
#ifdef __cplusplus
}
#endif
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
qDebug() << avcodec_configuration();
return a.exec();
}