记录ffmpeg使用x264
参考:https://blog.csdn.net/MR_kdcon/article/details/114599697
一.编译x264
./configure --enable-shared --enable-static --prefix=/usr/local/x264_64 --host=mingw64
二.编译fdk-aac
导入CmakeList编译
参考:
https://blog.csdn.net/icsecurity/article/details/118382410?spm=1001.2014.3001.5501
一.编译ffmpeg
a.编译MINGW64版本
./configure --enable-gpl --enable-nonfree --enable-libx264 --enable-shared --enable-debug --extra-cflags=-I/usr/local/x264_64/include --extra-ldflags=-L/usr/local/x264_64 --prefix=/usr/local/ffmpeg_64
b.编译mvsc版本
参考:https://zhuanlan.zhihu.com/p/205156264
先切换到MVSC环境,打开64位msys2环境
"E:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
msys2_shell.cmd -use-full-path -mingw64
需要把下面的define注释掉
#if defined(_MSC_VER)
#define X264_API_IMPORTS 1
#endif
因为在x264.h中有定义这样
#ifdef X264_API_IMPORTS
#define X264_API __declspec(dllimport)
#else
#define X264_API
#endif
不知道为何__declspec(dllimport)会报错,可能时需要dll文件吧
然后下面的命令编译mvsc版本的ffmpeg
./configure --toolchain=msvc --enable-cross-compile --enable-gpl --enable-nonfree --enable-libx264 --enable-shared --enable-debug --extra-cflags=-I/usr/local/x264_64/include --extra-ldflags=-LIBPATH:/usr/local/x264_64/lib --prefix=/usr/local/ffmpeg_64
ffplay编译
主要要自己新建一个sdl2.pc放在PKG_CONFIG_PATH环境变量指向的目录下
sdl2.pc文件内容如下,要根据你实际路径修改prefix
prefix=/usr/local/SDL2-devel-2.0.14-VC/SDL2-2.0.14
libdir=${prefix}/lib/x64
includedir=${prefix}/include
Name: sdl2
Description: sdl2
Version: 2.0.14
Libs: -L${libdir} -lsdl2
然后开始配置和编译,主要是多了--enable-sdl2 --enable-ffplay
./configure --toolchain=msvc --enable-cross-compile --enable-gpl --enable-nonfree --enable-libx264 --enable-shared --enable-debug --enable-sdl2 --enable-ffplay --extra-cflags="-I/usr/local/x264_64/include -I/usr/local/SDL2-devel-2.0.14-VC/SDL2-2.0.14/include" --extra-ldflags="-LIBPATH:/usr/local/x264_64/lib -LIBPATH:/usr/local/SDL2-devel-2.0.14-VC/SDL2-2.0.14/lib/x64" --prefix=/usr/local/ffmpeg_64