ffmpeg库的接口都是c函数,其头文件也没有extern “C”的声明,所以在cpp文件里调用ffmpeg函数要注意。
在头文件中应该加上:
#ifdef __cplusplus
extern "C" {
#endif
//#include <xxxx>
#ifdef __cplusplus
} // endof extern "C"
#endif
或者在头文件中使用:
#define inline _inline
extern "C"
{
#include <libavutil/avutil.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
//……
}
下载ffmpeg-dev和ffmpeg-shared两个文件,注意版本要对应一致。https://ffmpeg.zeranoe.com/builds/ 。dev中提供include 和 lib 两个文件夹;shared提供bin文件夹。
特别注意:下载x32位和x64位的区别。这里是指所创建的项目是32位还是64位的,不是指系统的位数。
1、设置额外的include
2、设置外部连接lib
3、在 连接器-》输入 中添加
avcodec.lib
avformat.lib
avutil.lib
swscale.lib
swresample.lib
avfilter.lib