FFmpeg函式庫編譯
FFmpeg的官方網站:http://www.ffmpeg.org
編譯任何平台的FFmpeg事實上都是一項相當大的挑戰,因為相關連的函式庫數量相當多,而組合狀態也相當多,相依函式庫變動率也十分高。這裡說明的只是一般的設定及建議,如果您想要自行編譯FFmpeg,可能要多花一點時間來嘗試適合自己的組態。
FFmpeg on Windows
預先編譯好的FFmpeg on Windows的函式庫在:
http://ffmpeg.zeranoe.com/builds可以找到。
我們建議您使用這個版本。
下載完成後,我們建議您執行下列指令,用以保證產生的.lib檔是可以鏈結的:
x64架構
LIB /machine:x64 /def:avcodec-56.def /OUT:avcodec.lib
LIB /machine:x64 /def:avdevice-56.def /OUT:avdevice.lib
LIB /machine:x64 /def:avfilter-5.def /OUT:avfilter.lib
LIB /machine:x64 /def:avformat-56.def /OUT:avformat.lib
LIB /machine:x64 /def:avutil-54.def /OUT:avutil.lib
LIB /machine:x64 /def:postproc-53.def /OUT:postproc.lib
LIB /machine:x64 /def:swresample-1.def /OUT:swresample.lib
LIB /machine:x64 /def:swscale-3.def /OUT:swscale.lib
|
重建完成以後,include內的檔案請複製到
CiosAudio/Platforms/Windows/FFmpeg/include
*.lib請複製到
CiosAudio/Platforms/Windows/FFmpeg/lib/x64
x86架構
LIB /machine:x86 /def:avcodec-56.def /OUT:avcodec.lib
LIB /machine:x86 /def:avdevice-56.def /OUT:avdevice.lib
LIB /machine:x86 /def:avfilter-5.def /OUT:avfilter.lib
LIB /machine:x86 /def:avformat-56.def /OUT:avformat.lib
LIB /machine:x86 /def:avutil-54.def /OUT:avutil.lib
LIB /machine:x86 /def:postproc-53.def /OUT:postproc.lib
LIB /machine:x86 /def:swresample-1.def /OUT:swresample.lib
LIB /machine:x86 /def:swscale-3.def /OUT:swscale.lib
|
重建完成以後,include內的檔案請複製到
CiosAudio/Platforms/Windows/FFmpeg/include
*.lib請複製到
CiosAudio/Platforms/Windows/FFmpeg/lib/x86
FFmpeg on Mac OS X
Mac OS X平台上,我們建議您全部都編譯成靜態函式庫。
編譯的方式:
export ARENA=/usr/local
./configure \
--cc=clang \
--prefix=$ARENA \
--extra-cflags="-I$ARENA/include" \
--extra-ldflags="-L$ARENA/lib" \
--disable-shared \
--enable-static \
--enable-gpl \
--enable-nonfree \
--enable-version3 \
--disable-ssse3 \
--disable-programs \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-network \
--disable-sdl \
--disable-indev=qtkit \
--disable-indev=x11grab_xcb \
--enable-hardcoded-tables \
--enable-runtime-cpudetect \
--enable-pthreads \
--enable-postproc \
--enable-filters \
--enable-mdct \
--enable-rdft \
--enable-fft \
--enable-bzlib \
--enable-zlib \
--enable-libtwolame \
--enable-libmp3lame \
--enable-libgsm \
--enable-libwavpack \
--enable-libvorbis \
--enable-libfaac
make
sudo make install
|
由於每台編譯的機器環境均不相同,編譯成應用程式時,如果缺少了某個函式庫,通常都出現許多錯誤訊息,您必須自行尋找缺少的項目,一般而言,詢問其他人的幫助並不太大。
這個版本編譯出來需要與以下的函式庫鏈結:
- CaCore
- avcodec
- avdevice
- avfilter
- avformat
- avutil
- swresample
- swscale
- postproc
- iconv
- z
- bz2
- pthread
- twolame
- mp3lame
- gsm
- wavpack
- ogg
- vorbis
- vorbisenc
- vorbisfile
- faac
Framework需要以下列表:
- CoreAudio
- CoreServices
- AudioUnit
- AudioToolBox
- CoreFoundation
- CoreVideo
- VideoDecodeAcceleration
- Accelerate
Two LAME
Two LAME的官方網址位於:
http://www.twolame.org
編譯的方式:
./configure --disable-shared --enable-static --prefix=/usr/local
make
sudo make install
|
LAME
LAME的官方網址位於:
http://lame.sourceforge.net
編譯的方式:
./configure --disable-shared --enable-static --prefix=/usr/local
make
sudo make install
|
GSM
GSM的官方網址位於:
http://libgsm.sourcearchive.com
編譯的方式:
make
sudo cp -f inc/gsm.h /usr/local/include
sudo cp -f lib/libgsm.a /usr/local/lib
|
Wav Pack
Wav Pack的官方網址位於:
http://www.wavpack.com
編譯的方式:
./configure --disable-shared --enable-static --prefix=/usr/local
make
sudo make install
|
ogg
ogg的官方網址位於:
http://xiph.org/ogg
編譯的方式:
./configure --disable-shared --enable-static --prefix=/usr/local
make
sudo make install
|
vorbis
vorbis的官方網址位於:
http://xiph.org/vorbis
編譯的方式:
./configure --disable-shared --enable-static --prefix=/usr/local
make
sudo make install
|
FAAC
FAAC的官方網址位於:
http://www.audiocoding.com/faac.html
編譯的方式:
./configure --disable-shared --enable-static --prefix=/usr/local
make
sudo make install
|
FFmpeg on Linux
Debian
尚未測試。
Fedora
尚未測試。
Ubuntu
Ubuntu 14.10
sudo apt-get remove ffmpeg
sudo apt-get update
sudo apt-get install build-essential subversion git-core checkinstall yasm texi2html libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libvorbis-dev libvpx-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev libx264-dev
cd
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab
make
sudo checkinstall --pkgname=ffmpeg --pkgversion "4:SVN-r`LANG=C svn info | grep Revision | awk '{ print $NF }'`" --backup=no --deldoc=yes --fstrans=no --default
hash x264 ffmpeg ffplay
|
Arch Linux
尚未測試。
FFmpeg on FreeBSD
尚未測試。
FFmpeg on Solaris
Solaris(11.2)平台上,我們建議您全部都編譯成靜態函式庫。此外您必須先編譯YASM,安裝到Solaris系統當中。
編譯的方式:
YASM
YASM的官方網址位於:
http://yasm.tortall.net/
編譯的方式:
./configure --prefix=/usr
make
sudo make install
|
Two LAME
Two LAME的編譯方式與Mac OS X相同。
LAME
LAME的官方網址位於:
http://lame.sourceforge.net
編譯的方式:
Solaris編譯之前,必須先修改掉libmp3lame/i386/Makefile.in當中的一個錯誤語法:
ECHO ?= echo
修改成
ECHO = echo
然後依照以下方式編譯:
./configure --disable-shared --enable-static --prefix=/usr/local
make
sudo make install
|
GSM
GSM的編譯方式與Mac OS X相同。
Wav Pack
Wav Pack的編譯方式與Mac OS X相同。
ogg
ogg的編譯方式與Mac OS X相同。
vorbis
vorbis的編譯方式與Mac OS X相同。
FAAC
FAAC的編譯方式與Mac OS X相同。
編譯的方式:
export ARENA=/usr/local
./configure \
--cc=clang \
--prefix=$ARENA \
--extra-cflags="-I$ARENA/include" \
--extra-ldflags="-L$ARENA/lib" \
--disable-shared \
--enable-static \
--enable-gpl \
--enable-nonfree \
--enable-version3 \
--disable-programs \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-network \
--disable-sdl \
--disable-indev=qtkit \
--disable-indev=x11grab_xcb \
--enable-hardcoded-tables \
--enable-runtime-cpudetect \
--enable-pthreads \
--enable-postproc \
--enable-filters \
--enable-mdct \
--enable-rdft \
--enable-fft \
--enable-bzlib \
--enable-zlib \
--enable-libtwolame \
--enable-libmp3lame \
--enable-libgsm \
--enable-libwavpack \
--enable-libvorbis \
--enable-libfaac
gmake
gmake install
|
由於每台編譯的機器環境均不相同,編譯成應用程式時,如果缺少了某個函式庫,通常都出現許多錯誤訊息,您必須自行尋找缺少的項目,一般而言,詢問其他人的幫助並不太大。
FFmpeg on iPhone OS
尚未測試。
FFmpeg on Android
在您編譯Android平台之前,您必須先建立基本環境,請參考《
Android平台編譯》。
Two LAME
Two LAME的官方網址位於:
http://www.twolame.org
編譯的方式:
#!/bin/sh
export DEPOT=/CIOS/Qt/Android/Depot
export ARENA=/CIOS/Android/Arena
export SROOT=/CIOS/Qt/Android/Scripts/armv7
export BUILD=/home/Linkers/Android
cd $BUILD
export TWOLAMEVER=0.3.13
tar xvf $DEPOT/twolame-$TWOLAMEVER.tar.gz
cd twolame-$TWOLAMEVER
echo "Compile Two LAME $TWOLAMEVER"
export CC="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-gcc --sysroot=$ANDROID_SYS_ROOT/sysroot"
export CXX="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-g++ --sysroot=$ANDROID_SYS_ROOT/sysroot"
export AR="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ar"
export RANLIB="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ranlib"
export SYSROOT="$ANDROID_SYS_ROOT/sysroot"
export PATH="$ANDROID_SYS_ROOT/bin":$PATH
./configure \
--host=arm-linux \
--disable-shared \
--enable-static \
--with-sysroot=$SYSROOT \
--prefix=$ARENA
make
sudo make install
|
LAME
LAME的官方網址位於:
http://lame.sourceforge.net
編譯的方式:
#!/bin/sh
export DEPOT=/CIOS/Qt/Android/Depot
export ARENA=/CIOS/Android/Arena
export SROOT=/CIOS/Qt/Android/Scripts/armv7
export BUILD=/home/Linkers/Android
cd $BUILD
export LAMEVER=3.99.5
tar xvf $DEPOT/lame-$LAMEVER.tar.gz
cd lame-$LAMEVER
echo "Compile LAME $LAMEVER"
export CC="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-gcc --sysroot=$ANDROID_SYS_ROOT/sysroot"
export CXX="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-g++ --sysroot=$ANDROID_SYS_ROOT/sysroot"
export AR="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ar"
export RANLIB="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ranlib"
export SYSROOT="$ANDROID_SYS_ROOT/sysroot"
export PATH="$ANDROID_SYS_ROOT/bin":$PATH
./configure \
--host=arm-linux \
--disable-shared \
--enable-static \
--with-sysroot=$SYSROOT \
--prefix=$ARENA
make
sudo make install
|
GSM
GSM的官方網址位於:
http://libgsm.sourcearchive.com
我們使用專為Android修改過Makefile的GSM版本,下載處《
GSM 1.0.13 For Android》,原始版本的下載處《
GSM 1.0.13》。
編譯的方式:
#!/bin/sh
export DEPOT=/CIOS/Qt/Android/Depot
export ARENA=/CIOS/Android/Arena
export SROOT=/CIOS/Qt/Android/Scripts/armv7
export BUILD=/home/Linkers/Android
cd $BUILD
export GSMVER=1.0.13
tar xvf $DEPOT/libgsm_$GSMVER.android.tar.gz
cd gsm-1.0-pl13
echo "Compile GSM $GSMVER"
export CC="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-gcc --sysroot=$ANDROID_SYS_ROOT/sysroot"
export CXX="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-g++ --sysroot=$ANDROID_SYS_ROOT/sysroot"
export AR="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ar"
export RANLIB="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ranlib"
export SYSROOT="$ANDROID_SYS_ROOT/sysroot"
export PATH="$ANDROID_SYS_ROOT/bin":$PATH
export GSM_INSTALL_ROOT=$ARENA
make
sudo cp -f inc/gsm.h $ARENA/include
sudo cp -f lib/libgsm.a $ARENA/lib
echo "Done"
|
iconv
編譯的方式:
#!/bin/sh
export DEPOT=/CIOS/Qt/Android/Depot
export ARENA=/CIOS/Android/Arena
export SROOT=/CIOS/Qt/Android/Scripts/armv7
export BUILD=/home/Linkers/Android
cd $BUILD
export ICONVVER=1.14
tar xvf $DEPOT/libiconv-$ICONVVER.tar.gz
cd libiconv-$ICONVVER
echo "Compile iconv $ICONVVER"
export CC="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-gcc --sysroot=$ANDROID_SYS_ROOT/sysroot"
export CXX="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-g++ --sysroot=$ANDROID_SYS_ROOT/sysroot"
export AR="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ar"
export RANLIB="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ranlib"
export SYSROOT="$ANDROID_SYS_ROOT/sysroot"
export PATH="$ANDROID_SYS_ROOT/bin":$PATH
export ACC=arm-linux
./configure \
--host=$ACC \
--disable-shared \
--enable-static \
--with-sysroot=$SYSROOT \
--prefix=$ARENA
make
sudo cp -f include/iconv.h $ARENA/include
sudo cp -f lib/.libs/libiconv.a $ARENA/lib
sudo make install
|
Wav Pack
Wav Pack的官方網址位於:
http://www.wavpack.com
編譯的方式:
#!/bin/sh
export DEPOT=/CIOS/Qt/Android/Depot
export ARENA=/CIOS/Android/Arena
export SROOT=/CIOS/Qt/Android/Scripts/armv7
export BUILD=/home/Linkers/Android
cd $BUILD
export WAVPACKVER=4.70.0
tar xvf $DEPOT/wavpack-$WAVPACKVER.tar.bz2
cd wavpack-$WAVPACKVER
echo "Compile Wav Pack $WAVPACKVER"
export CC="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-gcc --sysroot=$ANDROID_SYS_ROOT/sysroot"
export CXX="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-g++ --sysroot=$ANDROID_SYS_ROOT/sysroot"
export AR="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ar"
export RANLIB="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ranlib"
export SYSROOT="$ANDROID_SYS_ROOT/sysroot"
export PATH="$ANDROID_SYS_ROOT/bin":$PATH
export CFLAGS="-I$ARENA/include"
export LDFLAGS="-L$ARENA/lib"
export ACC=arm-linux
./configure \
--host=$ACC \
--disable-shared \
--enable-static \
--with-sysroot=$SYSROOT \
--prefix=$ARENA
make
sudo make install
|
ogg
ogg的官方網址位於:
http://xiph.org/ogg
編譯的方式:
#!/bin/sh
export DEPOT=/CIOS/Qt/Android/Depot
export ARENA=/CIOS/Android/Arena
export SROOT=/CIOS/Qt/Android/Scripts/armv7
export BUILD=/home/Linkers/Android
cd $BUILD
export OGGVER=1.3.1
tar xvf $DEPOT/libogg-$OGGVER.tar.gz
cd libogg-$OGGVER
echo "Compile OGG $TWOLAMEVER"
export CC="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-gcc --sysroot=$ANDROID_SYS_ROOT/sysroot"
export CXX="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-g++ --sysroot=$ANDROID_SYS_ROOT/sysroot"
export AR="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ar"
export RANLIB="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ranlib"
export SYSROOT="$ANDROID_SYS_ROOT/sysroot"
export PATH="$ANDROID_SYS_ROOT/bin":$PATH
export ACC=arm-linux
./configure \
--host=$ACC \
--disable-shared \
--enable-static \
--with-sysroot=$SYSROOT \
--prefix=$ARENA
make
sudo make install
|
vorbis
vorbis的官方網址位於:
http://xiph.org/vorbis
編譯的方式:
#!/bin/sh
export DEPOT=/CIOS/Qt/Android/Depot
export ARENA=/CIOS/Android/Arena
export SROOT=/CIOS/Qt/Android/Scripts/armv7
export BUILD=/home/Linkers/Android
cd $BUILD
export VORBISVER=1.3.4
tar xvf $DEPOT/libvorbis-$VORBISVER.tar.gz
cd libvorbis-$VORBISVER
echo "Compile Vorbis $VORBISVER"
export CC="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-gcc --sysroot=$ANDROID_SYS_ROOT/sysroot"
export CXX="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-g++ --sysroot=$ANDROID_SYS_ROOT/sysroot"
export AR="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ar"
export RANLIB="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ranlib"
export SYSROOT="$ANDROID_SYS_ROOT/sysroot"
export PATH="$ANDROID_SYS_ROOT/bin":$PATH
export CFLAGS="-I$ARENA/include"
export LDFLAGS="-L$ARENA/lib"
export ACC=arm-linux
./configure \
--host=$ACC \
--disable-shared \
--enable-static \
--with-sysroot=$SYSROOT \
--prefix=$ARENA
make
sudo make install
|
FAAC
FAAC的官方網址位於:
http://www.audiocoding.com/faac.html
編譯的方式:
#!/bin/sh
export DEPOT=/CIOS/Qt/Android/Depot
export ARENA=/CIOS/Android/Arena
export SROOT=/CIOS/Qt/Android/Scripts/armv7
export BUILD=/home/Linkers/Android
cd $BUILD
export FAACVER=1.28
tar xvf $DEPOT/faac-$FAACVER.tar.gz
cd faac-$FAACVER
echo "Compile FAAC $FAACVER"
export CC="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-gcc --sysroot=$ANDROID_SYS_ROOT/sysroot"
export CXX="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-g++ --sysroot=$ANDROID_SYS_ROOT/sysroot"
export AR="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ar"
export RANLIB="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ranlib"
export SYSROOT="$ANDROID_SYS_ROOT/sysroot"
export PATH="$ANDROID_SYS_ROOT/bin":$PATH
export ACC=arm-linux
./configure \
--host=$ACC \
--disable-shared \
--enable-static \
--with-sysroot=$SYSROOT \
--prefix=$ARENA
make
sudo make install
|
FFmpeg
編譯的方式:
#!/bin/sh
# one step compilation for android armv7
export DEPOT=/CIOS/Qt/Android/Depot
export ARENA=/CIOS/Android/Arena
export SROOT=/CIOS/Qt/Android/Scripts/armv7
export BUILD=/home/Linkers/Android
cd $BUILD
export FFMPEGVER=2.5
tar xvf $DEPOT/ffmpeg-$FFMPEGVER.tar.bz2
cd ffmpeg-$FFMPEGVER
echo "Compile FFmpeg $FFMPEGVER"
export CC="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-gcc --sysroot=$ANDROID_SYS_ROOT/sysroot"
export CXX="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-g++ --sysroot=$ANDROID_SYS_ROOT/sysroot"
export AR="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ar"
export LD="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ld"
export NM="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-nm"
export RANLIB="$ANDROID_SYS_ROOT/bin/arm-linux-androideabi-ranlib"
export SYSROOT="$ANDROID_SYS_ROOT/sysroot"
export PATH="$ANDROID_SYS_ROOT/bin":$PATH
./configure \
--target-os=linux \
--prefix=$ARENA \
--sysinclude=$SYSROOT/usr/include \
--enable-cross-compile \
--extra-libs="-lgcc" \
--arch=arm \
--cc=arm-linux-androideabi-gcc \
--cross-prefix=arm-linux-androideabi- \
--nm=$NM \
--ranlib=$RANLIB \
--sysroot=$SYSROOT \
--extra-cflags=" -O3 -Wall -mthumb -pipe -fpic -DANDROID -DNDEBUG -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -Wa,--noexecstack -fasm -Wno-psabi -fno-short-enums -fstrict-aliasing -Werror=strict-aliasing -finline-limit=300 -ffast-math -fmodulo-sched -fmodulo-sched-allow-regmoves -mfloat-abi=softfp -mfpu=vfp -march=armv7 -I$ARENA/include" \
--disable-shared \
--enable-static \
--extra-ldflags="-Wl,-rpath-link=$SYSROOT/usr/lib -L$SYSROOT/usr/lib -L$ARENA/lib -nostdlib -lc -lm -ldl -llog" \
--disable-everything \
--disable-symver \
--disable-doc \
--disable-ffplay \
--disable-ffmpeg \
--disable-ffprobe \
--disable-ffserver \
--disable-network \
--disable-iconv \
--enable-nonfree \
--enable-protocol=file \
--enable-libwavpack \
--enable-libtwolame \
--enable-libmp3lame \
--enable-libgsm \
--enable-libwavpack \
--enable-libfaac \
--enable-libvorbis \
--enable-zlib \
--enable-avformat \
--enable-avutil \
--enable-avcodec \
--enable-avfilter \
--enable-avdevice \
--enable-swresample \
--enable-swscale \
--enable-postproc \
--enable-demuxers \
--enable-muxers \
--enable-decoders \
--enable-encoders \
--enable-parsers \
--enable-asm
make
sudo make install
|