zoukankan      html  css  js  c++  java
  • 在32位的Ubuntu 11.04中为Android NDK r6编译FFmpeg0.10.1版Android中使用FFmpeg媒体库

    1:编译过程中所遇到问题以及解决方式

    编译方法原则:

    1. FFmpeg  的源代码不能做任何改动;
    2. FFmpeg  的配置可以根据需要改变; 
    3. 用脚本配置

    Update for ndk-r6:      

    Note that you may need to create ./android/armv7-a/ folder in the ffmpeg directory yourself .

    如果你是再ndk-r6情况下这步是必须的。

    相关文件:

    config.sh

    #!/bin/bash
    ######################################################
    # Usage:
    # put this script in top of FFmpeg source tree
    # ./build_android
    #
    # It generates binary for following architectures:
    # ARMv6 
    # ARMv6+VFP 
    # ARMv7+VFPv3-d16 (Tegra2)
    # ARMv7+Neon (Cortex-A8)
    #
    # Customizing:
    # 1. Feel free to change ./configure parameters for more features
    # 2. To adapt other ARM variants
    # set $CPU and $OPTIMIZE_CFLAGS 
    # call build_one
    ######################################################
    #change these three lines if you want to build using different vesion of Android ndk
    #build_one is for ndk 5, and build_one_r6 is for ndk 6
    NDK=~/ffmpeg/android-ndk-r6
    PLATFORM=$NDK/platforms/android-8/arch-arm/
    PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
    function build_one_r6
    {
    ./configure \
        --disable-shared \
        --enable-static \
        --enable-gpl \
        --enable-version3 \
        --enable-nonfree \
        --disable-doc \
        --disable-ffmpeg \
        --disable-ffplay \
        --disable-ffprobe \
        --disable-ffserver \
        --disable-avdevice \
        --disable-avfilter \
        --disable-postproc \
        --enable-small \
        --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
        --enable-cross-compile \
        --target-os=linux \
        --extra-cflags="-I$PLATFORM/usr/include" \
        --extra-ldflags="-L$PLATFORM/usr/lib -nostdlib" \
        --arch=arm \
        --disable-symver \
        --disable-debug \
        --disable-stripping \
        $ADDITIONAL_CONFIGURE_FLAG
    sed -i 's/HAVE_LRINT 0/HAVE_LRINT 1/g' config.h
    sed -i 's/HAVE_LRINTF 0/HAVE_LRINTF 1/g' config.h
    sed -i 's/HAVE_ROUND 0/HAVE_ROUND 1/g' config.h
    sed -i 's/HAVE_ROUNDF 0/HAVE_ROUNDF 1/g' config.h
    sed -i 's/HAVE_TRUNC 0/HAVE_TRUNC 1/g' config.h
    sed -i 's/HAVE_TRUNCF 0/HAVE_TRUNCF 1/g' config.h
    make clean
    make  -j4 install
    $PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
    $PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib  -soname libffmpeg.so -shared -nostdlib  -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog  --warn-once  --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
    }
    function build_one_r6_2
    {
    $PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
    $PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib  -soname libffmpeg.so -shared -nostdlib  -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog  --warn-once  --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
    }
    #arm v6
    #CPU=armv6
    #OPTIMIZE_CFLAGS="-marm -march=$CPU"
    #PREFIX=./android/$CPU 
    #ADDITIONAL_CONFIGURE_FLAG=
    #build_one
    #arm v7vfpv3
    CPU=armv7-a
    OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
    PREFIX=./android/$CPU
    ADDITIONAL_CONFIGURE_FLAG=
    #build_one
    build_one_r6
    #arm v7vfp
    #CPU=armv7-a
    #OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "
    #PREFIX=./android/$CPU-vfp
    #ADDITIONAL_CONFIGURE_FLAG=
    #build_one
    #arm v7n
    #CPU=armv7-a
    #OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8"
    #PREFIX=./android/$CPU 
    #ADDITIONAL_CONFIGURE_FLAG=--enable-neon
    #build_one
    #arm v6+vfp
    #CPU=armv6
    #OPTIMIZE_CFLAGS="-DCMP_HAVE_VFP -mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU"
    #PREFIX=./android/${CPU}_vfp 
    #ADDITIONAL_CONFIGURE_FLAG=
    #build_one

    创建一个Android.mk文件,放在 /root/develop/workspace/jni目录
    内容参考Android.mk 

    开始编译.  这个过程需要几分钟,耐心等待吧。

    尽量别去修改ffmpeg本身源代码去处理错误,以免后期用到某些功能点是出现不可避免的错误  

    编译完成!
    Compile arm    : ffmpeg <= vc1test.c
    Compile arm    : ffmpeg <= vc1testenc.c
    Compile arm    : ffmpeg <= voc.c
    Compile arm    : ffmpeg <= vocdec.c
    Compile arm    : ffmpeg <= vocenc.c
    Compile arm    : ffmpeg <= vorbiscomment.c
    Compile arm    : ffmpeg <= vqf.c
    Compile arm    : ffmpeg <= wav.c
    Compile arm    : ffmpeg <= wc3movie.c
    Compile arm    : ffmpeg <= westwood.c
    Compile arm    : ffmpeg <= wtv.c
    Compile arm    : ffmpeg <= wtvdec.c
    Compile arm    : ffmpeg <= wv.c
    Compile arm    : ffmpeg <= xa.c
    Compile arm    : ffmpeg <= xwma.c
    Compile arm    : ffmpeg <= yop.c
    Compile arm    : ffmpeg <= yuv4mpeg.c
    SharedLibrary  : libffmpeg.so
    Install        : libffmpeg.so => libs/armeabi/libffmpeg.so
  • 相关阅读:
    POJ 1251 Jungle Roads
    1111 Online Map (30 分)
    1122 Hamiltonian Cycle (25 分)
    POJ 2560 Freckles
    1087 All Roads Lead to Rome (30 分)
    1072 Gas Station (30 分)
    1018 Public Bike Management (30 分)
    1030 Travel Plan (30 分)
    22. bootstrap组件#巨幕和旋转图标
    3. Spring配置文件
  • 原文地址:https://www.cnblogs.com/tinkl/p/2485616.html
Copyright © 2011-2022 走看看