在Win10 子系统 Ubuntu中编译Win32 版本FFmpeg 给唧唧特供

标签: none

FFmpeg 4.1.1 直接下载编译好的版本实在是太大了64位的61M,32位的 59M. 但是唧唧用不到所有的功能所以一直用着旧版本的只有21M的FFmpeg苟命.但是由于编码更新了,旧的也出现了问题在此不得不更新FFmpeg了.

直接更新存在一个流量费贵的问题,59M的压缩后也有18M 在算上几万次的下载请求.流量费非常昂贵.
于是想到了编译一个只有唧唧需要功能的FFmpeg给唧唧使用.
于是有了这篇文章~ 编译完的只有3M 哟!~

这个是笔记,不是教程...

首先是交叉编译的环境安装. 大概是这些.

apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools yasm lua5.2 libtool automake autoconf autopoint make gettext pkg-config

唧唧需要的模块
flv解流|混流、MP4混流、h264解码器、HEVC解码、文件协议、mp3编码(libmp3lame)

唧唧使用静态编译.

首先编译 libmp3lame 3.100 FFmpeg 4.1.2需要3.98.3 以上版本的
libmp3lame-error.png
下载在这里 https://sourceforge.net/projects/lame/files/lame/

3.100版本编译 Windows 版本会遇到一个错误 Cannot export lame_init_old: symbol not defined
bug 跟踪连接 https://sourceforge.net/p/lame/bugs/487/

Version 3.100 breaks Windows compatibility when using libiconv since frontend/parse.c now depends on langinfo.h.
I'm using the MinGW-w64 (GCC-compatible) compiler.

Looks better now, except for this error:
Cannot export lame_init_old: symbol not defined

But I was able to build both static and shared libraries for Windows after removing lame_init_old from include/libmp3lame.sym.

大致解释就是编辑 include/libmp3lame.sym 文件,把 lame_init_old 删除 就可以编译了.

libmp3lame 编译参数

./configure --host=i686-w64-mingw32 --enable-static=yes --enable-shared=no
make -j
sudo make install

接下来是编译FFmpeg

FFmpeg 大部分参数是由 TG群的Xuan 提供的,感谢
Snipaste_2019-04-02_01-33-14.png

./configure --arch=x86 --target-os=mingw32 --cross-prefix=i686-w64-mingw32- --disable-debug --disable-doc --disable-ffplay --disable-ffprobe --enable-static --disable-shared --disable-network --disable-autodetect --disable-decoders --enable-gpl --enable-version3 --enable-decoder=h264,hevc,aac*,mp3*,mp4 --disable-encoders --disable-demuxers --enable-demuxer=concat,mov,m4v,flv,mp3 --disable-muxers --enable-muxer=flv,mp4,mp3 --enable-encoder=libmp3lame,mp3 --disable-parsers --enable-parser=h264,hevc --disable-protocols --enable-protocol=concat,file --disable-bsfs --enable-bsf=h264_metadata,h264_mp4toannexb,hevc_mp4toannexb,hevc_metadata --disable-filters --enable-filter=concat,aresample --disable-iconv --enable-small --enable-libmp3lame --extra-ldflags="-L/usr/local/lib" --extra-cflags="-I/usr/local/include"

make -j

要注意的小问题
undefined reference to '_lame_set_VBR_quality'
lame_set_VBR_quality (again)

/usr/local/lib/libmp3lame.so is your native lame library (for linux). you should cross-compile lame for windows
如果 libmp3lame 没有交叉编译,编译出来的是 Linux下使用的.so库. 你应该交叉编译给Windows用.

仅编译mp3 转换
Best config for ffmpeg to convert MP3 file only
How to compile ffmpeg to get only mp3 and mp4 support


扫描二维码,在手机上阅读!

添加新评论