用 NDK 編譯 ffmpeg 到 Android 平臺

LiuYinChina發表於2013-10-01
紅色表示,可直接Copy到shell執行
export FFMPEG=ffmpeg-2.7.1

wget http://www.ffmpeg.org/releases/${FFMPEG}.tar.bz2
tar jxvf ${FFMPEG}.tar.bz2
cd ${FFMPEG}

#這一步不是必要的
vi configure
g/SLIBNAME_WITH_MAJOR=\'$(SLIBNAME)\.$(LIBMAJOR)\'/s//SLIBNAME_WITH_MAJOR=\'$(SLIBNAME)\'/g

vi ./build_android.sh

#!/bin/bash

SYSROOT=$NDK_HOME/platforms/android-18/arch-arm/
TOOLCHAIN=$NDK_HOME/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86

CPU=arm
PREFIX=$(pwd)/android
ADDI_CFLAGS="-marm"

function build_android
{
./configure --prefix=$PREFIX --enable-neon --enable-armv5te --enable-shared --disable-static --disable-doc --enable-ffmpeg --disable-ffplay --enable-ffprobe --enable-ffserver --disable-avdevice --disable-doc --disable-symver --disable-debug --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- --target-os=linux --arch=arm --enable-cross-compile --sysroot=$SYSROOT --extra-cflags="-Os -fpic $ADDI_CFLAGS" --extra-ldflags="$ADDI_LDFLAGS" $ADDITIONAL_CONFIGURE_FLAG --enable-hwaccel=h263_vaapi --enable-hwaccel=mpeg1_vdpau --enable-hwaccel=mpeg4_vdpau --enable-hwaccel=h263_vdpau --enable-hwaccel=mpeg1_xvmc --enable-hwaccel=vc1_dxva2 --enable-hwaccel=h264_dxva2 --enable-hwaccel=mpeg2_dxva2 --enable-hwaccel=vc1_vaapi --enable-hwaccel=h264_vaapi --enable-hwaccel=mpeg2_vaapi --enable-hwaccel=vc1_vdpau --enable-hwaccel=h264_vda --enable-hwaccel=mpeg2_vdpau --enable-hwaccel=wmv3_dxva2 --enable-hwaccel=h264_vda_old --enable-hwaccel=mpeg2_xvmc --enable-hwaccel=wmv3_vaapi --enable-hwaccel=h264_vdpau --enable-hwaccel=mpeg4_vaapi --enable-hwaccel=wmv3_vdpau --enable-decoder=aac --enable-decoder=bink --enable-decoder=gsm_ms --enable-decoder=aac_latm --enable-decoder=binkaudio_dct --enable-decoder=h261 --enable-decoder=aasc --enable-decoder=binkaudio_rdft --enable-decoder=h263 --enable-decoder=ac3 --enable-decoder=bintext --enable-decoder=h263i --enable-decoder=ac3_fixed --enable-decoder=bmp --enable-decoder=h263p --enable-decoder=adpcm_4xm --enable-decoder=bmv_audio --enable-decoder=h264 --enable-decoder=adpcm_adx --enable-decoder=bmv_video --enable-decoder=h264_crystalhd --enable-decoder=adpcm_afc --enable-decoder=brender_pix --enable-decoder=h264_vda --enable-decoder=adpcm_ct --enable-decoder=c93 --enable-decoder=h264_vdpau --enable-decoder=adpcm_dtk --enable-decoder=cavs --enable-decoder=hevc --enable-decoder=adpcm_ea --enable-decoder=cdgraphics --enable-decoder=hnm4_video --enable-decoder=adpcm_ea_maxis_xa --enable-decoder=cdxl --enable-decoder=huffyuv --enable-decoder=adpcm_ea_r1 --enable-decoder=cinepak --enable-decoder=iac --enable-decoder=adpcm_ea_r2 --enable-decoder=cljr --enable-decoder=idcin --enable-decoder=adpcm_ea_r3 --enable-decoder=cllc --enable-decoder=idf --enable-decoder=adpcm_ea_xas --enable-decoder=comfortnoise --enable-decoder=iff_byterun1 --enable-decoder=adpcm_g722 --enable-decoder=cook --enable-decoder=iff_ilbm --enable-decoder=adpcm_g726 --enable-decoder=cpia --enable-decoder=imc --enable-decoder=adpcm_g726le --enable-decoder=cscd --enable-decoder=indeo2 --enable-decoder=adpcm_ima_amv --enable-decoder=cyuv --enable-decoder=indeo3 --enable-decoder=adpcm_ima_apc --enable-decoder=dca --enable-decoder=indeo4 --enable-decoder=adpcm_ima_dk3 --enable-decoder=dfa --enable-decoder=indeo5 --enable-decoder=adpcm_ima_dk4 --enable-decoder=dirac --enable-decoder=interplay_dpcm --enable-decoder=adpcm_ima_ea_eacs --enable-decoder=dnxhd --enable-decoder=interplay_video --enable-decoder=adpcm_ima_ea_sead --enable-decoder=dpx --enable-decoder=jacosub --enable-decoder=adpcm_ima_iss --enable-decoder=dsd_lsbf --enable-decoder=jpeg2000 --enable-decoder=adpcm_ima_oki --enable-decoder=dsd_lsbf_planar --enable-decoder=jpegls --enable-decoder=adpcm_ima_qt --enable-decoder=dsd_msbf --enable-decoder=jv --enable-decoder=adpcm_ima_rad --enable-decoder=dsd_msbf_planar --enable-decoder=kgv1 --enable-decoder=adpcm_ima_smjpeg --enable-decoder=dsicinaudio --enable-decoder=kmvc --enable-decoder=adpcm_ima_wav --enable-decoder=dsicinvideo --enable-decoder=lagarith --enable-decoder=adpcm_ima_ws --enable-decoder=dvbsub --enable-decoder=libcelt --enable-decoder=adpcm_ms --enable-decoder=dvdsub --enable-decoder=libfdk_aac --enable-decoder=adpcm_sbpro_2 --enable-decoder=dvvideo --enable-decoder=libgsm --enable-decoder=adpcm_sbpro_3 --enable-decoder=dxa --enable-decoder=libgsm_ms --enable-decoder=adpcm_sbpro_4 --enable-decoder=dxtory --enable-decoder=libilbc --enable-decoder=adpcm_swf --enable-decoder=eac3 --enable-decoder=libopencore_amrnb --enable-decoder=adpcm_thp --enable-decoder=eacmv --enable-decoder=libopencore_amrwb --enable-decoder=adpcm_vima --enable-decoder=eamad --enable-decoder=libopenjpeg --enable-decoder=adpcm_xa --enable-decoder=eatgq --enable-decoder=libopus --enable-decoder=adpcm_yamaha --enable-decoder=eatgv --enable-decoder=libschroedinger --enable-decoder=aic --enable-decoder=eatqi --enable-decoder=libspeex --enable-decoder=alac --enable-decoder=eightbps --enable-decoder=libstagefright_h264 --enable-decoder=alias_pix --enable-decoder=eightsvx_exp --enable-decoder=libutvideo --enable-decoder=als --enable-decoder=eightsvx_fib --enable-decoder=libvorbis --enable-decoder=amrnb --enable-decoder=escape124 --enable-decoder=libvpx_vp8 --enable-decoder=amrwb --enable-decoder=escape130 --enable-decoder=libvpx_vp9 --enable-decoder=amv --enable-decoder=evrc --enable-decoder=libzvbi_teletext --enable-decoder=anm --enable-decoder=exr --enable-decoder=loco --enable-decoder=ansi --enable-decoder=ffv1 --enable-decoder=mace3 --enable-decoder=ape --enable-decoder=ffvhuff --enable-decoder=mace6 --enable-decoder=ass --enable-decoder=ffwavesynth --enable-decoder=mdec --enable-decoder=asv1 --enable-decoder=fic --enable-decoder=metasound --enable-decoder=asv2 --enable-decoder=flac --enable-decoder=microdvd --enable-decoder=atrac1 --enable-decoder=flashsv --enable-decoder=mimic --enable-decoder=atrac3 --enable-decoder=flashsv2 --enable-decoder=mjpeg --enable-decoder=atrac3p --enable-decoder=flic --enable-decoder=mjpegb --enable-decoder=aura --enable-decoder=flv --enable-decoder=mlp --enable-decoder=aura2 --enable-decoder=fourxm --enable-decoder=mmvideo --enable-decoder=avrn --enable-decoder=fraps --enable-decoder=motionpixels --enable-decoder=avrp --enable-decoder=frwu --enable-decoder=movtext --enable-decoder=avs --enable-decoder=g2m --enable-decoder=mp1 --enable-decoder=avui --enable-decoder=g723_1 --enable-decoder=mp1float --enable-decoder=ayuv --enable-decoder=g729 --enable-decoder=mp2 --enable-decoder=bethsoftvid --enable-decoder=gif --enable-decoder=mp2float --enable-decoder=bfi --enable-decoder=gsm --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=pcm_u32be --enable-decoder=tmv --enable-decoder=mp3adufloat --enable-decoder=pcm_u32le --enable-decoder=truehd --enable-decoder=mp3float --enable-decoder=pcm_u8 --enable-decoder=truemotion1 --enable-decoder=mp3on4 --enable-decoder=pcm_zork --enable-decoder=truemotion2 --enable-decoder=mp3on4float --enable-decoder=pcx --enable-decoder=truespeech --enable-decoder=mpc7 --enable-decoder=pgm --enable-decoder=tscc --enable-decoder=mpc8 --enable-decoder=pgmyuv --enable-decoder=tscc2 --enable-decoder=mpeg1_vdpau --enable-decoder=pgssub --enable-decoder=tta --enable-decoder=mpeg1video --enable-decoder=pictor --enable-decoder=twinvq --enable-decoder=mpeg2_crystalhd --enable-decoder=pjs --enable-decoder=txd --enable-decoder=mpeg2video --enable-decoder=png --enable-decoder=ulti --enable-decoder=mpeg4 --enable-decoder=ppm --enable-decoder=utvideo --enable-decoder=mpeg4_crystalhd --enable-decoder=prores --enable-decoder=v210 --enable-decoder=mpeg4_vdpau --enable-decoder=prores_lgpl --enable-decoder=v210x --enable-decoder=mpeg_vdpau --enable-decoder=ptx --enable-decoder=v308 --enable-decoder=mpeg_xvmc --enable-decoder=qcelp --enable-decoder=v408 --enable-decoder=mpegvideo --enable-decoder=qdm2 --enable-decoder=v410 --enable-decoder=mpl2 --enable-decoder=qdraw --enable-decoder=vb --enable-decoder=msa1 --enable-decoder=qpeg --enable-decoder=vble --enable-decoder=msmpeg4_crystalhd --enable-decoder=qtrle --enable-decoder=vc1 --enable-decoder=msmpeg4v1 --enable-decoder=r10k --enable-decoder=vc1_crystalhd --enable-decoder=msmpeg4v2 --enable-decoder=r210 --enable-decoder=vc1_vdpau --enable-decoder=msmpeg4v3 --enable-decoder=ra_144 --enable-decoder=vc1image --enable-decoder=msrle --enable-decoder=ra_288 --enable-decoder=vcr1 --enable-decoder=mss1 --enable-decoder=ralf --enable-decoder=vima --enable-decoder=mss2 --enable-decoder=rawvideo --enable-decoder=vmdaudio --enable-decoder=msvideo1 --enable-decoder=realtext --enable-decoder=vmdvideo --enable-decoder=mszh --enable-decoder=rl2 --enable-decoder=vmnc --enable-decoder=mts2 --enable-decoder=roq --enable-decoder=vorbis --enable-decoder=mvc1 --enable-decoder=roq_dpcm --enable-decoder=vp3 --enable-decoder=mvc2 --enable-decoder=rpza --enable-decoder=vp5 --enable-decoder=mxpeg --enable-decoder=rv10 --enable-decoder=vp6 --enable-decoder=nellymoser --enable-decoder=rv20 --enable-decoder=vp6a --enable-decoder=nuv --enable-decoder=rv30 --enable-decoder=vp6f --enable-decoder=on2avc --enable-decoder=rv40 --enable-decoder=vp7 --enable-decoder=opus --enable-decoder=s302m --enable-decoder=vp8 --enable-decoder=paf_audio --enable-decoder=sami --enable-decoder=vp9 --enable-decoder=paf_video --enable-decoder=sanm --enable-decoder=vplayer --enable-decoder=pam --enable-decoder=sgi --enable-decoder=vqa --enable-decoder=pbm --enable-decoder=sgirle --enable-decoder=wavpack --enable-decoder=pcm_alaw --enable-decoder=shorten --enable-decoder=webp --enable-decoder=pcm_bluray --enable-decoder=sipr --enable-decoder=webvtt --enable-decoder=pcm_dvd --enable-decoder=smackaud --enable-decoder=wmalossless --enable-decoder=pcm_f32be --enable-decoder=smacker --enable-decoder=wmapro --enable-decoder=pcm_f32le --enable-decoder=smc --enable-decoder=wmav1 --enable-decoder=pcm_f64be --enable-decoder=smvjpeg --enable-decoder=wmav2 --enable-decoder=pcm_f64le --enable-decoder=snow --enable-decoder=wmavoice --enable-decoder=pcm_lxf --enable-decoder=sol_dpcm --enable-decoder=wmv1 --enable-decoder=pcm_mulaw --enable-decoder=sonic --enable-decoder=wmv2 --enable-decoder=pcm_s16be --enable-decoder=sp5x --enable-decoder=wmv3 --enable-decoder=pcm_s16be_planar --enable-decoder=srt --enable-decoder=wmv3_crystalhd --enable-decoder=pcm_s16le --enable-decoder=ssa --enable-decoder=wmv3_vdpau --enable-decoder=pcm_s16le_planar --enable-decoder=subrip --enable-decoder=wmv3image --enable-decoder=pcm_s24be --enable-decoder=subviewer --enable-decoder=wnv1 --enable-decoder=pcm_s24daud --enable-decoder=subviewer1 --enable-decoder=ws_snd1 --enable-decoder=pcm_s24le --enable-decoder=sunrast --enable-decoder=xan_dpcm --enable-decoder=pcm_s24le_planar --enable-decoder=svq1 --enable-decoder=xan_wc3 --enable-decoder=pcm_s32be --enable-decoder=svq3 --enable-decoder=xan_wc4 --enable-decoder=pcm_s32le --enable-decoder=tak --enable-decoder=xbin --enable-decoder=pcm_s32le_planar --enable-decoder=targa --enable-decoder=xbm --enable-decoder=pcm_s8 --enable-decoder=targa_y216 --enable-decoder=xface --enable-decoder=pcm_s8_planar --enable-decoder=text --enable-decoder=xl --enable-decoder=pcm_u16be --enable-decoder=theora --enable-decoder=xsub --enable-decoder=pcm_u16le --enable-decoder=thp --enable-decoder=xwd --enable-decoder=pcm_u24be --enable-decoder=tiertexseqvideo --enable-decoder=y41p --enable-decoder=pcm_u24le --enable-decoder=tiff --enable-decoder=yop --enable-decoder=yuv4 --enable-decoder=zerocodec --enable-decoder=zmbv --enable-decoder=zero12v --enable-decoder=zlib --enable-encoder=a64multi --enable-encoder=libopenjpeg --enable-encoder=pcm_u24be --enable-encoder=a64multi5 --enable-encoder=libopus --enable-encoder=pcm_u24le --enable-encoder=aac --enable-encoder=libschroedinger --enable-encoder=pcm_u32be --enable-encoder=ac3 --enable-encoder=libshine --enable-encoder=pcm_u32le --enable-encoder=ac3_fixed --enable-encoder=libspeex --enable-encoder=pcm_u8 --enable-encoder=adpcm_adx --enable-encoder=libtheora --enable-encoder=pcx --enable-encoder=adpcm_g722 --enable-encoder=libtwolame --enable-encoder=pgm --enable-encoder=adpcm_g726 --enable-encoder=libutvideo --enable-encoder=pgmyuv --enable-encoder=adpcm_ima_qt --enable-encoder=libvo_aacenc --enable-encoder=png --enable-encoder=adpcm_ima_wav --enable-encoder=libvo_amrwbenc --enable-encoder=ppm --enable-encoder=adpcm_ms --enable-encoder=libvorbis --enable-encoder=prores --enable-encoder=adpcm_swf --enable-encoder=libvpx_vp8 --enable-encoder=prores_aw --enable-encoder=adpcm_yamaha --enable-encoder=libvpx_vp9 --enable-encoder=prores_ks --enable-encoder=alac --enable-encoder=libwavpack --enable-encoder=qtrle --enable-encoder=alias_pix --enable-encoder=libwebp --enable-encoder=r10k --enable-encoder=amv --enable-encoder=libx264 --enable-encoder=r210 --enable-encoder=ass --enable-encoder=libx264rgb --enable-encoder=ra_144 --enable-encoder=asv1 --enable-encoder=libx265 --enable-encoder=rawvideo --enable-encoder=asv2 --enable-encoder=libxavs --enable-encoder=roq --enable-encoder=avrp --enable-encoder=libxvid --enable-encoder=roq_dpcm --enable-encoder=avui --enable-encoder=ljpeg --enable-encoder=rv10 --enable-encoder=ayuv --enable-encoder=mjpeg --enable-encoder=rv20 --enable-encoder=bmp --enable-encoder=movtext --enable-encoder=s302m --enable-encoder=cinepak --enable-encoder=mp2 --enable-encoder=sgi --enable-encoder=cljr --enable-encoder=mp2fixed --enable-encoder=snow --enable-encoder=comfortnoise --enable-encoder=mpeg1video --enable-encoder=sonic --enable-encoder=dca --enable-encoder=mpeg2video --enable-encoder=sonic_ls --enable-encoder=dnxhd --enable-encoder=mpeg4 --enable-encoder=srt --enable-encoder=dpx --enable-encoder=msmpeg4v2 --enable-encoder=ssa --enable-encoder=dvbsub --enable-encoder=msmpeg4v3 --enable-encoder=subrip --enable-encoder=dvdsub --enable-encoder=msvideo1 --enable-encoder=sunrast --enable-encoder=dvvideo --enable-encoder=nellymoser --enable-encoder=svq1 --enable-encoder=eac3 --enable-encoder=pam --enable-encoder=targa --enable-encoder=ffv1 --enable-encoder=pbm --enable-encoder=tiff --enable-encoder=ffvhuff --enable-encoder=pcm_alaw --enable-encoder=tta --enable-encoder=flac --enable-encoder=pcm_f32be --enable-encoder=utvideo --enable-encoder=flashsv --enable-encoder=pcm_f32le --enable-encoder=v210 --enable-encoder=flashsv2 --enable-encoder=pcm_f64be --enable-encoder=v308 --enable-encoder=flv --enable-encoder=pcm_f64le --enable-encoder=v408 --enable-encoder=g723_1 --enable-encoder=pcm_mulaw --enable-encoder=v410 --enable-encoder=gif --enable-encoder=pcm_s16be --enable-encoder=vorbis --enable-encoder=h261 --enable-encoder=pcm_s16be_planar --enable-encoder=wavpack --enable-encoder=h263 --enable-encoder=pcm_s16le --enable-encoder=webvtt --enable-encoder=h263p --enable-encoder=pcm_s16le_planar --enable-encoder=wmav1 --enable-encoder=huffyuv --enable-encoder=pcm_s24be --enable-encoder=wmav2 --enable-encoder=jpeg2000 --enable-encoder=pcm_s24daud --enable-encoder=wmv1 --enable-encoder=jpegls --enable-encoder=pcm_s24le --enable-encoder=wmv2 --enable-encoder=libaacplus --enable-encoder=pcm_s24le_planar --enable-encoder=xbm --enable-encoder=libfaac --enable-encoder=pcm_s32be --enable-encoder=xface --enable-encoder=libfdk_aac --enable-encoder=pcm_s32le --enable-encoder=xsub --enable-encoder=libgsm --enable-encoder=pcm_s32le_planar --enable-encoder=xwd --enable-encoder=libgsm_ms --enable-encoder=pcm_s8 --enable-encoder=y41p --enable-encoder=libilbc --enable-encoder=pcm_s8_planar --enable-encoder=yuv4 --enable-encoder=libmp3lame --enable-encoder=pcm_u16be --enable-encoder=zlib --enable-encoder=libopencore_amrnb --enable-encoder=pcm_u16le --enable-encoder=zmbv

make clean
make
make install
}

build_android

chmod a+x build_android.sh
./build_android.sh


工程已生成在 ffmpeg/android 下

相關文章