成功编译ffmpeg的android硬解码模块libstagefright

准备环境:

CentOS6.4 (64位)

ffmpeg源码:

git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
android NDK:
http://developer.android.com/tools/sdk/ndk/index.html

将ffmpeg/tools/build_libstagefright脚本移到ffmpeg目录下修改执行权限

chmod +x build_libstagefright

修改build_libstagefright内容:

#!/bin/bash
export NDK=/android-ndk-r9b #这里是指定NDK路径
if [ "$NDK" = "" ]; then
    echo NDK variable not set, assuming ${HOME}/android-ndk-r8d
    export NDK=${HOME}/android-ndk-r8d
fi
#第一次执行需要打开下面部分,下载所用资源
#echo "Fetching Android system headers"
#git clone --depth=1 --branch gingerbread-release git://github.com/CyanogenMod/android_frameworks_base.git ../android-source/frameworks/base
#git clone --depth=1 --branch gingerbread-release git://github.com/CyanogenMod/android_system_core.git ../android-source/system/core

#echo "Fetching Android libraries for linking"
# Libraries from any froyo/gingerbread device/emulator should work
# fine, since the symbols used should be available on most of them.
#if [ ! -d "../android-libs" ]; then
 #   if [ ! -f "../update-cm-7.0.3-N1-signed.zip" ]; then
#        wget http://download.cyanogenmod.com/get/update-cm-7.0.3-N1-signed.zip -P../
#    fi
#    unzip ../update-cm-7.0.3-N1-signed.zip system/lib/* -d../
#    mv ../system/lib ../android-libs
#    rmdir ../system
#fi


SYSROOT=$NDK/platforms/android-9/arch-arm
# Expand the prebuilt/* path into the correct one
TOOLCHAIN=`echo $NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64 `
export PATH=$TOOLCHAIN/bin:$PATH
ANDROID_SOURCE=../android-source
ANDROID_LIBS=../android-libs
ABI="armeabi-v7a"

rm -rf ../build/stagefright
mkdir -p ../build/stagefright

DEST=../build/stagefright
FLAGS="--target-os=linux --cross-prefix=arm-linux-androideabi- --arch=arm --cpu=armv7-a"
FLAGS="$FLAGS --sysroot=$SYSROOT"
FLAGS="$FLAGS --enable-shared --disable-demuxers --disable-muxers --disable-parsers --disable-avdevice --disable-filters --disable-programs --disable-encoders --disable-decoders --disable-decoder=h264 --disable-decoder=h264_vdpau --enable-decoder=libstagefright_h264 --enable-libstagefright-h264"

EXTRA_CFLAGS="-I$ANDROID_SOURCE/frameworks/base/include -I$ANDROID_SOURCE/system/core/include"
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$ANDROID_SOURCE/frameworks/base/media/libstagefright"
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$ANDROID_SOURCE/frameworks/base/include/media/stagefright/openmax"
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$NDK/sources/cxx-stl/gnu-libstdc++/4.6/include -I$NDK/sources/cxx-stl/gnu-libstdc++/4.6/libs/$ABI/include"

EXTRA_CFLAGS="$EXTRA_CFLAGS -march=armv7-a -mfloat-abi=softfp -mfpu=neon"
EXTRA_LDFLAGS="-Wl,--fix-cortex-a8 -L$ANDROID_LIBS -Wl,-rpath-link,$ANDROID_LIBS -L$NDK/sources/cxx-stl/gnu-libstdc++/4.6/libs/$ABI"
EXTRA_CXXFLAGS="-Wno-multichar -fno-exceptions -fno-rtti"
DEST="$DEST/$ABI"
FLAGS="$FLAGS --prefix=$DEST"

mkdir -p $DEST

echo $FLAGS --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" --extra-cxxflags="$EXTRA_CXXFLAGS" > $DEST/info.txt
./configure $FLAGS --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" --extra-cxxflags="$EXTRA_CXXFLAGS" | tee $DEST/configuration.txt
[ $PIPESTATUS == 0 ] || exit 1
make clean
make -j4
make install|| exit 1


ERROR: libstagefright_h264 not found

解决方法:

1. vim configure

2.找到

enabled libstagefright_h264  && require_cpp libstagefright_h264 "binder/ProcessState.h media/stagefright/MetaData.h
    media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h
    media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder -lgnustl_static

修改为

enabled libstagefright  && require_cpp libstagefright_h264 "binder/ProcessState.h media/stagefright/MetaData.h
    media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h
    media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder -lgnustl_static

3.再次编译就可以编译通过



你可能感兴趣的:(ffmpeg,android,视频编解码)