编译环境:
debian x64
ndk-r14b
1. 安装ndk-r14b
下载地址 http://mirrors.neusoft.edu.cn/android/repository/android-ndk-r14b-linux-x86_64.zip
安装:
cd /opt/workspace && unzip android-ndk-r14b-linux-x86_64.zip
2. ndk编译环境设置脚本: setup_build_env.sh
1 export NDK=/opt/workspace/android-ndk-r14b2 export PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt 3 export PLATFORM=$NDK/platforms/android-9/arch-arm4 export PREFIX=$(pwd)/android-lib
2.1 编译libx264
git clone git://git.videolan.org/x264.git. ./setup_build_env.sh cd x264./configure --prefix=$PREFIX --enable-static --enable-shared --enable-pic --disable-asm --disable-cli --host=arm-linux --cross-prefix=$PREBUILT/linux-x86_64/bin/arm-linux-androideabi- --sysroot=$PLATFORMmakemake installcd ..
2.2 编译libfdk-aac
git clone https://github.com/mstorsjo/fdk-aac.git. ./setup_build_envcd fdk-aac./autogen.shCFLAGS="-fpic -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_7__ -Wno-psabi -march=armv7 -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wa,--noexecstack -MMD -MP " CROSS_COMPILE=$PREBUILT/linux-x86_64/bin/arm-linux-androideabi-export CPPFLAGS="$CFLAGS"export CFLAGS="$CFLAGS"export CXXFLAGS="$CFLAGS" export CXX="${CROSS_COMPILE}g++ --sysroot=${PLATFORM}" export LDFLAGS="$LDFLAGS" export CC="${CROSS_COMPILE}gcc --sysroot=${PLATFORM}" export NM="${CROSS_COMPILE}nm" export STRIP="${CROSS_COMPILE}strip" export thout-mp4v2 RANLIB="${CROSS_COMPILE}ranlib" export AR="${CROSS_COMPILE}ar"./configure --prefix=$PREFIX --without-mp4v2 --host=arm-linux --enable-static --enable-shared makemake installcd ..
2.3 编译FFmpeg
. setup_build_env.shexport PREFIX=../ffmpeg-libmake cleanconfigure_normal() {./configure --target-os=linux --prefix=$PREFIX --enable-cross-compile --enable-runtime-cpudetect --disable-asm --arch=arm --cc=$PREBUILT/linux-x86_64/bin/arm-linux-androideabi-gcc --cross-prefix=$PREBUILT/linux-x86_64/bin/arm-linux-androideabi- --disable-stripping --nm=$PREBUILT/linux-x86_64/bin/arm-linux-androideabi-nm --sysroot=$PLATFORM --enable-gpl --enable-nonfree --enable-shared --enable-static --enable-small --enable-libx264 --enable-libfdk-aac --extra-cflags="-I ./deps/android-lib/include -fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated -mfloat-abi=softfp -marm -march=armv7-a" --extra-ldflags="-L ./deps/android-lib/lib"}configure_normalmakemake install
编译成功后安装目录如下:
ffmpeg-lib/├── bin│ ├── ffmpeg│ ├── ffprobe│ └── ffserver├── include│ ├── libavcodec│ │ ├── avcodec.h│ │ ├── avdct.h│ │ ├── avfft.h│ │ ├── d3d11va.h│ │ ├── dirac.h│ │ ├── dv_profile.h│ │ ├── dxva2.h│ │ ├── jni.h│ │ ├── mediacodec.h│ │ ├── qsv.h│ │ ├── vaapi.h│ │ ├── vda.h│ │ ├── vdpau.h│ │ ├── version.h│ │ ├── videotoolbox.h│ │ ├── vorbis_parser.h│ │ └── xvmc.h│ ├── libavdevice│ │ ├── avdevice.h│ │ └── version.h│ ├── libavfilter│ │ ├── avfiltergraph.h│ │ ├── avfilter.h│ │ ├── buffersink.h│ │ ├── buffersrc.h│ │ └── version.h│ ├── libavformat│ │ ├── avformat.h│ │ ├── avio.h│ │ └── version.h│ ├── libavutil│ │ ├── adler32.h│ │ ├── aes_ctr.h│ │ ├── aes.h│ │ ├── attributes.h│ │ ├── audio_fifo.h│ │ ├── avassert.h│ │ ├── avconfig.h│ │ ├── avstring.h│ │ ├── avutil.h│ │ ├── base64.h│ │ ├── blowfish.h│ │ ├── bprint.h│ │ ├── bswap.h│ │ ├── buffer.h│ │ ├── camellia.h│ │ ├── cast5.h│ │ ├── channel_layout.h│ │ ├── common.h│ │ ├── cpu.h│ │ ├── crc.h│ │ ├── des.h│ │ ├── dict.h│ │ ├── display.h│ │ ├── downmix_info.h│ │ ├── error.h│ │ ├── eval.h│ │ ├── ffversion.h│ │ ├── fifo.h│ │ ├── file.h│ │ ├── frame.h│ │ ├── hash.h│ │ ├── hmac.h│ │ ├── hwcontext_cuda.h│ │ ├── hwcontext_dxva2.h│ │ ├── hwcontext.h│ │ ├── hwcontext_qsv.h│ │ ├── hwcontext_vaapi.h│ │ ├── hwcontext_vdpau.h│ │ ├── imgutils.h│ │ ├── intfloat.h│ │ ├── intreadwrite.h│ │ ├── lfg.h│ │ ├── log.h│ │ ├── lzo.h│ │ ├── macros.h│ │ ├── mastering_display_metadata.h│ │ ├── mathematics.h│ │ ├── md5.h│ │ ├── mem.h│ │ ├── motion_vector.h│ │ ├── murmur3.h│ │ ├── opt.h│ │ ├── parseutils.h│ │ ├── pixdesc.h│ │ ├── pixelutils.h│ │ ├── pixfmt.h│ │ ├── random_seed.h│ │ ├── rational.h│ │ ├── rc4.h│ │ ├── replaygain.h│ │ ├── ripemd.h│ │ ├── samplefmt.h│ │ ├── sha512.h│ │ ├── sha.h│ │ ├── spherical.h│ │ ├── stereo3d.h│ │ ├── tea.h│ │ ├── threadmessage.h│ │ ├── timecode.h│ │ ├── time.h│ │ ├── timestamp.h│ │ ├── tree.h│ │ ├── twofish.h│ │ ├── version.h│ │ └── xtea.h│ ├── libpostproc│ │ ├── postprocess.h│ │ └── version.h│ ├── libswresample│ │ ├── swresample.h│ │ └── version.h│ └── libswscale│ ├── swscale.h│ └── version.h├── lib│ ├── libavcodec.a│ ├── libavcodec.so -> libavcodec.so.57.89.100│ ├── libavcodec.so.57 -> libavcodec.so.57.89.100│ ├── libavcodec.so.57.89.100│ ├── libavdevice.a│ ├── libavdevice.so -> libavdevice.so.57.6.100│ ├── libavdevice.so.57 -> libavdevice.so.57.6.100│ ├── libavdevice.so.57.6.100│ ├── libavfilter.a│ ├── libavfilter.so -> libavfilter.so.6.82.100│ ├── libavfilter.so.6 -> libavfilter.so.6.82.100│ ├── libavfilter.so.6.82.100│ ├── libavformat.a│ ├── libavformat.so -> libavformat.so.57.71.100│ ├── libavformat.so.57 -> libavformat.so.57.71.100│ ├── libavformat.so.57.71.100│ ├── libavutil.a│ ├── libavutil.so -> libavutil.so.55.58.100│ ├── libavutil.so.55 -> libavutil.so.55.58.100│ ├── libavutil.so.55.58.100│ ├── libpostproc.a│ ├── libpostproc.so -> libpostproc.so.54.5.100│ ├── libpostproc.so.54 -> libpostproc.so.54.5.100│ ├── libpostproc.so.54.5.100│ ├── libswresample.a│ ├── libswresample.so -> libswresample.so.2.7.100│ ├── libswresample.so.2 -> libswresample.so.2.7.100│ ├── libswresample.so.2.7.100│ ├── libswscale.a│ ├── libswscale.so -> libswscale.so.4.6.100│ ├── libswscale.so.4 -> libswscale.so.4.6.100│ ├── libswscale.so.4.6.100│ └── pkgconfig│ ├── libavcodec.pc│ ├── libavdevice.pc│ ├── libavfilter.pc│ ├── libavformat.pc│ ├── libavutil.pc│ ├── libpostproc.pc│ ├── libswresample.pc│ └── libswscale.pc└── share ├── doc │ └── ffmpeg ├── ffmpeg │ ├── examples │ ├── ffprobe.xsd │ ├── libvpx-1080p50_60.ffpreset │ ├── libvpx-1080p.ffpreset │ ├── libvpx-360p.ffpreset │ ├── libvpx-720p50_60.ffpreset │ └── libvpx-720p.ffpreset └── man ├── man1 └── man320 directories, 157 files