記錄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環境變量指向的目錄下
image.png
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