FFmpeg版本: 4.1.3
android-ndk-r19c, 44 MB (armeabi-v7a)
gcc-7: 9.7 MB (x86_64)
配置几乎相同:
对于android-ndk-19c:
我没有链接x264,在Linux x86_64下,x264是链接的,因此理论上Linux X86_64链接的代码比android的更多。
#!/bin/bash
# set the toolchain
TOOLCHAIN=$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64
CROSS_PREFIX=$TOOLCHAIN/bin/arm-linux-androideabi-
rm -f $(pwd)/compat/strtod.o
function build_one
{
#configure ffmpeg w/o libx264
./configure \
--prefix=$PREFIX \
--disable-everything --disable-programs --disable-doc \
--enable-ffmpeg --enable-jni \
--enable-encoder=aac \
--enable-encoder=mpeg4 \
--enable-encoder=pcm_u16le --enable-encoder=pcm_s16le \
--enable-encoder=yuv4 \
--enable-encoder=rawvideo \
--enable-encoder=wrapped_avframe \
--enable-decoder=aac --enable-decoder=aac_at --enable-decoder=aac_fixed \
--enable-decoder=aac_latm \
--enable-decoder=ac3 --enable-decoder=ac3_at --enable-decoder=ac3_fixed \
--enable-decoder=avs \
--enable-decoder=eac3 \
--enable-decoder=eac3_at \
--enable-decoder=h263 \
--enable-decoder=h264 \
--enable-decoder=hevc \
--enable-decoder=mp1 --enable-decoder=mp1_at --enable-decoder=mp1float \
--enable-decoder=mp2 \
--enable-decoder=mp2_at \
--enable-decoder=mp2float \
--enable-decoder=mp3 --enable-decoder=mp3_at --enable-decoder=mp3float \
--enable-decoder=vp8 --enable-decoder=vp9 \
--enable-decoder=mpeg1video \
--enable-decoder=mpeg2video \
--enable-decoder=mpeg4 \
--enable-decoder=mpegvideo \
--enable-decoder=pcm_u16le --enable-decoder=pcm_s16le \
--enable-decoder=yuv4 \
--enable-decoder=rawvideo \
--enable-decoder=wrapped_avframe \
--enable-muxer=mpegts \
--enable-muxer=mp4 \
--enable-muxer=matroska --enable-muxer=matroska_audio --enable-muxer=webm \
--enable-muxer=h264 \
--enable-muxer=hevc \
--enable-muxer=rawvideo \
--enable-muxer=adts \
--enable-muxer=yuv4mpegpipe \
--enable-demuxer=aac \
--enable-demuxer=ac3 \
--enable-demuxer=eac3 \
--enable-demuxer=m4v \
--enable-demuxer=matroska \
--enable-demuxer=mp3 \
--enable-demuxer=mpegps \
--enable-demuxer=mpegts \
--enable-demuxer=mpegvideo \
--enable-demuxer=h263 \
--enable-demuxer=h264 \
--enable-demuxer=hevc \
--enable-demuxer=mov \
--enable-demuxer=rawvideo \
--enable-demuxer=yuv4mpegpipe \
--enable-parser=aac \
--enable-parser=aac_latm \
--enable-parser=ac3 \
--enable-parser=h263 \
--enable-parser=h264 \
--enable-parser=hevc \
--enable-parser=mpeg4video \
--enable-parser=mpegaudio \
--enable-parser=mpegvideo \
--enable-parser=vp8 \
--enable-parser=vp9 \
--enable-protocol=file \
--enable-bsf=aac_adtstoasc \
--enable-bsf=h264_mp4toannexb \
--enable-bsf=hevc_mp4toannexb \
--enable-bsf=mpeg4_unpack_bframes \
--enable-filter=scale \
--disable-zlib --disable-xlib --disable-iconv --disable-alsa \
--disable-libxcb_shape --disable-libxcb_xfixes --disable-lzma \
--disable-sdl2 --disable-sndio --disable-bzlib --disable-libxcb \
--disable-hwaccels \
--target-os=android \
--enable-cross-compile \
--toolchain=clang-usan \
--cross-prefix=$CROSS_PREFIX \
--cc=$TOOLCHAIN/bin/armv7a-linux-androideabi28-clang \
--cxx=$TOOLCHAIN/bin/armv7a-linux-androideabi28-clang++ \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
--sysroot=$TOOLCHAIN/sysroot $ADDITIONAL_CONFIG_FLAG
make clean
make -j4
make install
}
CPU=armeabi-v7a
mkdir -p $(pwd)/android/$CPU
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS=""
ADDI_LDFLAGS="-Wl,-Bsymbolic"
ADDITIONAL_CONFIG_FLAG="--arch=arm"
build_one
完成并将其剥离后,会生成44MB的ffmpeg,这太可怕了,但我对此一无所知,我尝试添加-Os CFLAGS,但这无济于事。
这是X86_64:
#!/bin/bash
configure()
{
CPU=$1
HOST=linux
PREFIX=$(pwd)/$HOST/$CPU
ADDI_CFLAGS="-I$(pwd)/../x264-stable/$HOST/$CPU/include"
ADDI_LDFLAGS="-L$(pwd)/../x264-stable/$HOST/$CPU/lib"
ADDITIONAL_CONFIG_FLAG=""
./configure \
--prefix=$PREFIX \
--disable-everything --disable-programs --disable-doc \
--enable-ffmpeg --enable-libx264 --enable-gpl \
--enable-encoder=aac \
--enable-encoder=libx264 \
--enable-encoder=mpeg4 \
--enable-encoder=pcm_u16le --enable-encoder=pcm_s16le \
--enable-encoder=yuv4 \
--enable-encoder=rawvideo \
--enable-encoder=wrapped_avframe \
--enable-decoder=aac \
--enable-decoder=aac_at \
--enable-decoder=aac_fixed \
--enable-decoder=aac_latm \
--enable-decoder=ac3 --enable-decoder=ac3_at --enable-decoder=ac3_fixed \
--enable-decoder=avs \
--enable-decoder=eac3 \
--enable-decoder=eac3_at \
--enable-decoder=h263 \
--enable-decoder=h264 \
--enable-decoder=hevc \
--enable-decoder=mp1 --enable-decoder=mp1_at --enable-decoder=mp1float \
--enable-decoder=mp2 \
--enable-decoder=mp2_at \
--enable-decoder=mp2float \
--enable-decoder=mp3 --enable-decoder=mp3_at --enable-decoder=mp3float \
--enable-decoder=vp8 --enable-decoder=vp9 \
--enable-decoder=mpeg1video \
--enable-decoder=mpeg2video \
--enable-decoder=mpeg4 \
--enable-decoder=mpegvideo \
--enable-decoder=pcm_u16le --enable-decoder=pcm_s16le \
--enable-decoder=yuv4 \
--enable-decoder=rawvideo --enable-decoder=wrapped_avframe \
--enable-muxer=mpegts \
--enable-muxer=mp4 \
--enable-muxer=matroska --enable-muxer=matroska_audio --enable-muxer=webm \
--enable-muxer=h264 \
--enable-muxer=hevc \
--enable-muxer=rawvideo \
--enable-muxer=adts \
--enable-muxer=yuv4mpegpipe \
--enable-demuxer=aac \
--enable-demuxer=ac3 \
--enable-demuxer=eac3 \
--enable-demuxer=m4v \
--enable-demuxer=matroska \
--enable-demuxer=mp3 \
--enable-demuxer=mpegps \
--enable-demuxer=mpegts \
--enable-demuxer=mpegvideo \
--enable-demuxer=h263 \
--enable-demuxer=h264 \
--enable-demuxer=hevc \
--enable-demuxer=mov \
--enable-demuxer=rawvideo \
--enable-demuxer=yuv4mpegpipe \
--enable-parser=aac \
--enable-parser=aac_latm \
--enable-parser=ac3 \
--enable-parser=h263 \
--enable-parser=h264 \
--enable-parser=hevc \
--enable-parser=mpeg4video \
--enable-parser=mpegaudio \
--enable-parser=mpegvideo \
--enable-parser=vp8 \
--enable-parser=vp9 \
--enable-protocol=file \
--enable-bsf=aac_adtstoasc \
--enable-bsf=h264_mp4toannexb \
--enable-bsf=hevc_mp4toannexb \
--enable-bsf=mpeg4_unpack_bframes \
--enable-filter=scale \
--disable-zlib --disable-xlib --disable-iconv \
--disable-alsa --disable-libxcb_shape --disable-libxcb_xfixes \
--disable-lzma --disable-sdl2 --disable-sndio \
--disable-bzlib --disable-libxcb \
--disable-hwaccels \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS"
}
build()
{
make clean
cpu=$1
echo "build $cpu"
configure $cpu
make -j4
make install
}
build linux_x86_64