ffmpeg库编译加文字_ffmpeg第三方库编译记录
最近在研究ffmpeg的編譯,之前使用的Ubuntu,需要安裝虛擬機,非常麻煩,所以后來改研究在Windows平臺編譯。
一開始遇到很多挫折,參考了網(wǎng)上很多的帖子,但要么不全要么內(nèi)容已過期,經(jīng)過我的反復試驗或研究,最終搞定了。在此記錄一下,也希望能對編譯ffmpeg的朋友們有所幫助。
首先安裝Mingw和Msys平臺,可以參考我其他幾篇轉(zhuǎn)載的帖子,基本都不會有問題
然后從ffmpeg官網(wǎng)下載源碼,可以選擇最新的Git測試版或穩(wěn)定版(我下載的是ffmpeg-1.1),編譯方式都大同小異,如果不需要第三方庫的話,編譯選項如下(shared和static只能有一個為enable):
./configure --enable-static --disable-shared --enable-memalign-hack --arch=x86 --target-os=mingw32 --pkg-config=pkg-config --enable-runtime-cpudetect --disable-debug --enable-pthreads
make
make install
下面介紹各種第三方庫的編譯。為了方便編譯,所有庫均先解壓到[mingw]/msys/1.0/home/[username]根目錄,然后在mingw shell中cd命令定位到庫文件夾下。
X264
編譯安裝:
./configure --enable-win32thread
make
make install
cp?-iv?x264.h?x264_config.h?/mingw/include
cp?-iv?libx264.a?/mingw/lib
cp?-iv?x264.pc?/mingw/lib/pkgconfig
ffmpeg編譯參數(shù):--enable-gpl --enable-libx264
LAME 3.99.5
編譯安裝:
./configure --enable-export=full --enable-static --disable-shared --disable-frontend
make
make install
ffmpeg編譯參數(shù):--enable-libmp3lame
librtmp 2.3
http://rtmpdump.mplayerhq.hu/,下載rtmpdump-2.3.tgz(網(wǎng)上有帖子說是rtmpdump-2.3-windows.zip,但我下載了,里面都沒有makefile)
librtmp依賴于zlib和openssl,所以要先編譯兩個庫,見下面:
Zlib 1.2.7
http://zlib.net/,下載zlib-1.2.7.tar.gz
make -f win32/Makefile.gcc
cp?-iv?zlib1.dll?/mingw/bin
cp?-iv?zconf.h?zlib.h?/mingw/include
cp?-iv?libz.a?/mingw/lib
cp win32/Makefile.gcc Makefile.gcc
ffmpeg編譯參數(shù):--enable-zlib
OpenSSL 1.0.1
http://www.openssl.org/,下載openssl-1.0.1c.tar.gz
./configure mingw --prefix=`pwd`/win32libs -DL_ENDIAN -DOPENSSL_NO_HW
make
make install
編譯完成后,把當前目錄的win32libs子文件夾下的include和lib分別拷貝到mingw32,以供后面librtmp使用
注意:openssl的編譯需要在安裝Mingw時包含Perl 5環(huán)境,如果沒有的話,可到網(wǎng)上下載(我用的是5.16.2版,見http://www.cpan.org/src/README.html),下載后編譯參數(shù)如下:
./Configure -des -Dprefix=$HOME/localperl
make
make test
make install
ffmpeg編譯參數(shù):--enable-nonfree --enable libopenssl
librtmp的編譯命令如下:
make SYS=mingw
make SYS=mingw install
注意:編譯ffmpeg時會提示“ERROR: ? librtmp not found”錯誤,主要是因為一些library沒鏈接好,不知道是否為ffmpeg的Bug。解決辦法是在configure文件中“enabled librtmp”一行最后要添加“?-lwinmm -lwsock32 -lgdi32”
ffmpeg編譯參數(shù):--enable-librtmp
xvidcore?1.3.2
http://www.xvid.org,下載xvidcore-1.3.2.tar.gz
編譯安裝:
cd?xvidcore/build/generic
./configure?--prefix=/mingw
執(zhí)行到這里后,搜索xvidcore/build/generic?目錄下面所有文件(我的版本是platform.inc中有兩處)中的?-mno-cygwin?這個選項, 這個選項已經(jīng)不被GCC支持,全部刪除后繼續(xù)。
make
make install
cp?-iv?\=build/xvidcore.dll.a?/mingw/lib/libxvidcore.dll.a
ffmpeg編譯參數(shù):--enable-libxvid
libgsm?1.0.13-3
編譯安裝:
make
mkdir /mingw/include/gsm
cp inc/gsm.h /mingw/include/gsm
cp lib/libgsm.a /mingw/lib
ffmpeg編譯參數(shù):--enable-libgsm
libogg
供libvorbis和libtheora用
解壓,編譯安裝:
./configure –prefix=/olibs –disable-shared
make
make install
LIBVorbis 1.3.3
編譯安裝:
./configure
make
make install
ffmpeg編譯參數(shù):--enable-libvorbis
LIBTheora?1.1.1
http://xiph.org/downloads/,下載libtheora-1.1.1.tar.bz2
編譯安裝:
./configure
make
make install
ffmpeg編譯參數(shù):--enable-libtheora
LIBSpeex 1.2rc1
./configure
make
make install
ffmpeg編譯參數(shù):--enable-libspeex
加入以上第三方庫以后,在ffmpeg中就可以下面的參數(shù)進行編譯:
./configure --enable-static --disable-shared --enable-memalign-hack --arch=x86 --target-os=mingw32 --pkg-config=pkg-config --enable-runtime-cpudetect --disable-debug --enable-pthreads?--enable-gpl?--enable-bzlib --enable-libx264?--enable-libgsm --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libxvid --enable-zlib--enable-openssl --enable-librtmp --enable-nonfree --enable-libspeex
make
make install
總結(jié)
以上是生活随笔為你收集整理的ffmpeg库编译加文字_ffmpeg第三方库编译记录的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ue编辑器拖拽上传图片_为百度UE编辑器
- 下一篇: api分层内部外部 spring_jav