1) requirement
- NDK r4 : please use NDK r4 instead of NDK r3.
- using NDK r4 new option, you can know the detail build option.
- please get ffmpeg http://www.ffmpeg.org/download.html
- please get libx264 http://www.videolan.org/developers/x264.html
2) build option for libx264
export ARM_ROOT=/export/home/android/ndk export ARM_INC=$ARM_ROOT/build/platforms/android-5/arch-arm/usr/include/ export ARM_LIB=$ARM_ROOT/build/platforms/android-5/arch-arm/usr/lib/ export ARM_TOOL=$ARM_ROOT/build/prebuilt/linux-x86/arm-eabi-4.4.0 export ARM_LIBO=$ARM_TOOL/lib/gcc/arm-eabi/4.4.0 export PATH=$ARM_TOOL/bin:$PATH export ARM_PRE=arm-eabi ./configure --prefix=/sdcard/arm_and \ --disable-gpac \ --extra-cflags=" -I$ARM_INC -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-prote ctor -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtu ne=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wa,--noexecstack - MMD -MP " \ --extra-ldflags=" -nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,nocopyreloc -Wl,-soname,/system /lib/libz.so -Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ARM_LIB -nostdlib $ARM_LIB/crtbegin_dynamic.o $AR M_LIB/crtend_android.o -lc -lm -ldl -lgcc " \ --cross-prefix=${ARM_PRE}- --disable-asm --disable-pthread --host=arm-linux \
3) build option for ffmpeg
export ARM_ROOT=/export/home/android/ndk export ARM_INC=$ARM_ROOT/build/platforms/android-5/arch-arm/usr/include/ export ARM_LIB=$ARM_ROOT/build/platforms/android-5/arch-arm/usr/lib/ export ARM_TOOL=$ARM_ROOT/build/prebuilt/linux-x86/arm-eabi-4.4.0 export ARM_LIBO=$ARM_TOOL/lib/gcc/arm-eabi/4.4.0 export PATH=$ARM_TOOL/bin:$PATH export ARM_PRE=arm-eabi export LIB_INC=/sdcard/arm_and/include export LIB_LIB=/sdcard/arm_and/lib ./configure \ --target-os=linux \ --arch=armv5te \ --enable-cross-compile \ --cc=$ARM_TOOL/bin/${ARM_PRE}-gcc \ --cross-prefix=$ARM_TOOL/bin/${ARM_PRE}- \ --extra-cflags=" -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ - D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -D ANDROID -Wa,--noexecstack -MMD -MP " \ --enable-static \ --disable-shared --enable-libx264 --enable-gpl \ --disable-asm --disable-yasm \ --prefix=/sdcard/arm_and \ --disable-amd3dnow --disable-amd3dnowext --disable-mmx --disable-mmx2 --disable-sse --disable-ssse3 \ --extra-cflags="-I$ARM_INC -std=gnu99 -I$LIB_INC " \ --extra-libs="-lc -lm -ldl -lgcc -lz -lx264 " \ --extra-ldflags=" -L$LIB_LIB -Wl,-rpath-link=$LIB_LIB -nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so -Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ARM_LIB -nostdlib $ARM_LIB/crtbegin_dynamic.o $ARM_LIB/crtend_android.o "
4) you will get 4 files ..
- ffmpeg, ffprobe, ffserver, x264.
- because we didn't ready SDL, we can't get ffplay.
5) how to use it ?
- because android support a few codecs, it's a little bit difficult to play some common files.
so, ffmpeg/ ffserver will run on android device to change stream format.
- for this one, Howard Chu, ffmpeg team member already check it. https://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2010-May/088706.html
- screen capture to use ffserver/ffmpeg to play H264/AAC / MPEG PS stream file on android emulator.
- unfortunately, the x264 doesn't work well on android, need to check X264/ffmpeg.
转帖:http://blog.sina.com.cn/s/blog_632b50940100nx96.html