1 准備工作
(1)libmp3lame庫
下載: wget http://downloads.sourceforge.net/lame/lame-3.99.tar.gz
解壓
編譯:./configure --prefix=/usr/local/arm --host=arm-none-linux-gnueabi
make
make install
編譯ok。
(2)libxvid庫(x264庫)
支持xvid x264,現在最流行的兩種高質量的壓縮格式,下載地址是:
http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
解壓后參考其readme文件,打開xvidcore/doc/INSTALL文件
基本上還是通常的三步曲,只不過configure文件換了個目錄,在build\generic路徑下
我們也看到庫支持vs2008編譯
./configure --prefix=/usr/local/arm --host=arm-none-linux-gnueabi
make
sudo make install
(3)FAAC庫的編譯安裝(貌似不需要)
從網上下載的源碼是faad2-2.0.tar,在Ubuntu上解壓后,由於是DOS格式的,執行下面語句會出錯
./bootstrap
我的執行步驟是
chmod +x bootstrap
dos2unix bootstrap
./bootstrap
報錯:
# ./bootstrap
configure.in:38: warning: underquoted definition of MY_CHECK_TYPEDEF_FROM_INCLUDE
configure.in:38: run info '(automake)Extending aclocal'
configure.in:38: or see http://www.gnu.org/software/automake/manual/automake.html#Extending-aclocal
./bootstrap: 5: ./bootstrap: libtoolize: not found
#
# apt-get install -y libtoolize
======================
./configure --prefix=/usr/local/arm --host=arm-none-linux-gnueabi
make
make install
2 配置及編譯安裝相關的選項有
--cross-prefix=PREFIX use PREFIX for compilation tools []
--enable-cross-compile assume a cross-compiler is used
--disable-ffserver disable ffserver build
--disable-postproc disable libpostproc build
--disable-ffplay disable ffplay build
--arch=ARCH select architecture []
--cpu=CPU select the minimum required CPU (affects
instruction selection, may crash on older CPUs)
--target-os=OS compiler targets OS []
--enable-libfaac enable FAAC support via libfaac [no]
--enable-libmp3lame enable MP3 encoding via libmp3lame [no]
--enable-libxvid enable Xvid encoding via xvidcore,
native MPEG-4/Xvid encoder exists [no]
--host-cc=HOSTCC use host C compiler HOSTCC
--host-cflags=HCFLAGS use HCFLAGS when compiling for host
--host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
--host-libs=HLIBS use libs HLIBS when linking for host
--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS []
--extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS []
--extra-libs=ELIBS add ELIBS []
--sysroot=PATH root of cross-build tree
--sysinclude=PATH location of cross-build system headers
實際的配置參數為:
./configure --prefix=/usr/local/arm \
--cross-prefix=arm-none-linux-gnueabi- --enable-cross-compile \
--target-os=linux --arch=armv6j \
--disable-ffserver --disable-postproc --disable-ffplay \
--enable-libmp3lame --enable-libxvid \
--sysinclude=/usr/local/arm/include \
--extra-cflags=-I/usr/local/arm/include \
--extra-ldflags=-L/usr/local/arm/lib \
--enable-gpl
其中要注意--cross-prefix的設置最后要有符號- , --arch選項要根據自己的GCC的選項加,我的編譯的選項有-march=armv6j,不清楚就不要加.
最后加--enable-gpl是因為--enable-libxvid選項,這造成了與--enable-libfaac選項沖突。
然后
make
以root身份運行
make install
3 測試
將安裝目錄中的ffmpeg程序拷貝到設備上,測試從視頻中截取一張圖片
ffmpeg -i 12.mp4 -y -f image2 -ss 10.010 -t 0.001 -s 320x240 test.jpg
成功執行,說明ffmpeg交叉編譯順利完成。