在VS上配置ffmpeg时,需要对ffmpeg进行编译,比较麻烦。这里直接给出编译好的库,来自该博客,版本为ffmpeg4.2.1,有32位和64的。
1. VS配置说明
编译测试代码的过程中可能会遇到缺少inttypes.h和stdint.h,配置方法和相关文件可在下面的百度网盘中下载:
链接:https://pan.baidu.com/s/1-1IQKpCLxpKNA56ZkFPq5g
提取码:5429
2. 测试代码
main.cpp
// TEST CODE
#pragma comment(lib,"avcodec.lib")
#pragma comment(lib,"avformat.lib")
#pragma comment(lib,"avutil.lib")
#pragma comment(lib,"avdevice.lib")
#pragma comment(lib,"avfilter.lib")
#pragma comment(lib,"postproc.lib")
#pragma comment(lib,"swresample.lib")
#pragma comment(lib,"swscale.lib")
#ifdef __cplusplus
extern "C" {
#endif
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#ifdef __cplusplus
}
#endif
int main()
{
rerurn 0;
}
3. linux编译
在linux上编译ffmpeg时,需要将原有的ffmpeg删掉,否则在使用的时候会报一些无法查找到函数的错误。通过该链接下载自己需要的版本,进行编译,编译方法比较简单,只需要下面几个步骤:
1. 将下载好的如ffmpeg-4.2.1.tar.gz解压得到ffmpg-4.2.1,cd进入ffmpeg
2. 执行:./configure,
3. 执行2的时候可能出现yasm找不到或者太old,需要先执行:sudo apt-get install yasm,再重新执行2
4. 执行:make -j8
5. 执行:make install
6. 结束:编译好的库在usr/local/lib和usr/local/include,在使用的时候把相关lib链接上即可。
参考链接:
https://blog.csdn.net/weixin_42949480/article/details/106439285?spm=1001.2014.3001.5502