mingw(msys2)编译ffmpeg

mingw(msys2)编译ffmpeg

首先要确保pacman环境是最新的,否则会出现莫名其妙的问题,可以执行“pacman -Syu”更新包

安装mingw:

pacman -S gcc mingw-w64-i686-toolchain yasm mingw-w64-i686-SDL2 //mingw32
pacman -S gcc mingw-w64-x86_64-toolchain yasm mingw-w64-x86_64-SDL2 //mingw64
pacman -S make

编译fribidi

首先从github clone代码:https://github.com/fribidi/fribidi
./autogen.sh //生成configure文件
./configure --prefix=/usr/local/fribidi
make
如果make时出现报错: undefined reference to `fribidi_char_set_name’ …, 我照着这个方法
https://github.com/fribidi/fribidi/commit/7c155c64ea91d9ad3a25cdf35c904e4cb2484448
改了代码,结果还是不行,最后重新从github clone代码下来,重新执行上述命令,竟然通过了…
如果出现“missing automake…”,或者提示automake版本不一致,参考
https://blog.csdn.net/hubbybob1/article/details/109244833,但我并没有成功,最后是重新down代码下来,编译通过
另外,很大可能以上问题你都不会遇到
make install

编译好后这个样子:
在这里插入图片描述

编译harfbuzz

github地址:https://github.com/harfbuzz/harfbuzz
./autogen.sh
./configure --prefix=/usr/local/harfbuzz
make

若提示,
在这里插入图片描述

则需要安装ragel,
32位 “pacman -S mingw-w64-i686-ragel”
64位:“pacman -S mingw-w64-x86_64-ragel
*/
make install

编译freetype

从官网下载源码:https://download.savannah.gnu.org/releases/freetype/
(也可以去github下载编译好的window版本,https://github.com/ubawurinna/freetype-windows-binaries)
./autogen.sh //生成configure文件
./configure --prefix=/usr/local/freetype
make
make install

编译好后这个样子:
在这里插入图片描述

编译libxml2

从gitlab下载源码:https://gitlab.gnome.org/GNOME/libxml2/
./autogen.sh
./configure --prefix=/usr/local/libxml2 --without-python
make
make install

编译fontconfig

从gitlab下载源码:https://gitlab.freedesktop.org/fontconfig/fontconfig
需要先安装gperf,pacman命令:pacman -S gperf

./autogen.sh
export PKG_CONFIG_PATH=/usr/local/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/freetype/lib/pkgconfig:$PKG_CONFIG_PATH
./configure --prefix=/usr/local/fontconfig --disable-docs --enable-libxml2
make
make install

编译libass

为什么要编译libass?因为subtitle filter需要用到libass去解码字体
export PKG_CONFIG_PATH=/usr/local/fontconfig/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/fribidi/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/freetype/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/harfbuzz/lib/pkgconfig:$PKG_CONFIG_PATH
./autogen.sh
./configure --prefix=/usr/local/libass
make
make install

编译libx264

(可选,ffmpeg自带x264解码,但不能编码)
./configure --prefix=/usr/local/libx264 --enable-shared
如果出现找不到c编译器的情况,首先确保gcc已经安装,再者如果是用mingw32去编译x264,则默认的gcc指令是
“gcc -m64…”,所以必须configure的时候指明host, 感谢这名博主的文章https://blog.csdn.net/fly_520/article/details/80625844*/
./configure --prefix=/usr/local/libx264 --enable-shared --host=i686-w64-mingw32 //mingw32
./configure --prefix=/usr/local/libx264 --enable-shared --host=x86_64-w64-mingw32 //mingw64,不用怀疑,确实叫“x86_64-w64-mingw32”不是“x86_64-w64-mingw64”,这一点我也很疑惑,有大佬明白的,麻烦告知一下
make
make install

编译ffmpeg

(当然如果你不需要libass支持, libx264编码,上面的库都可以不要,最简单的configure命令:./configure --prefix=…/build32 --disable-static --enable-shared --enable-sdl,另外你连sdl都可以不到,需要sdl是因为ffplay需要sdl的支持,编译之前执行pacman -S mingw-w64-i686-SDL2 或者pacman -S mingw-w64-x86_64-SDL2)
编译命令:
export PKG_CONFIG_PATH=/usr/local/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/fontconfig/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/fribidi/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/freetype/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/harfbuzz/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/libass/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/libx264/lib/pkgconfig:$PKG_CONFIG_PATH
./configure --prefix=/usr/local/ffmpeg --disable-static --enable-shared --enable-sdl --enable-gpl --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libass --enable-libx264 --enable-decoder=h264 --enable-encoder=libx264
make
make install

最后可以用到项目上了 ,我把ffplay拆分了一下,逻辑更清晰一些。github地址:https://github.com/lanbudao/ffplay
另外一个用c++写的播放器项目,参考了qtav和ffplay,视频渲染用的opengl,可以用到多个平台,github地址:https://github.com/lanbudao/ffproc (这个项目目前还处于开发阶段,但基本的播放功能都能用了)。

最后的最后,想偷懒,这里有编译好的32位的库https://download.csdn.net/download/theartedly/13625235,不需要币。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值