简体   繁体   English

带有NDK r10d的Android的FFMPEG 2.5.4构建

[英]FFMPEG 2.5.4 build for Android with NDK r10d

I'm trying to build FFmpeg for android following this tuto: http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/ 我正在尝试按照此Tuto为Android构建FFmpeg: http ://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/

I'm using: 我正在使用:

  • NDK r10d NDK r10d
  • FFMPEG 2.5.4 FFMPEG 2.5.4

I have tried to build on MacOs and Ubuntu and I get the same error when I execute ./build_android.sh: 我试图在MacOs和Ubuntu上构建,执行./build_android.sh时遇到相同的错误:

`Creating config.mak, config.h, and doc/config.texi...
./build_android.sh: line 16: --prefix=/Users/jesusmartin92/Documents/android-ndk-r10d/sources/ffmpeg-2.5.4/android/arm: No such file or directory
./build_android.sh: line 18: --enable-shared: command not found
./build_android.sh: line 20: --disable-static: command not found
./build_android.sh: line 22: --disable-doc: command not found
./build_android.sh: line 24: --disable-ffmpeg: command not found
./build_android.sh: line 26: --disable-ffplay: command not found
./build_android.sh: line 28: --disable-ffprobe: command not found
./build_android.sh: line 30: --disable-ffserver: command not found
./build_android.sh: line 32: --disable-avdevice: command not found
./build_android.sh: line 34: --disable-doc: command not found
./build_android.sh: line 36: --disable-symver: command not found
./build_android.sh: line 38: --cross-prefix=/Users/jesusmartin92/Documents/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-: No such file or directory
./build_android.sh: line 40: --target-os=linux: command not found
./build_android.sh: line 42: --arch=arm: command not found
./build_android.sh: line 44: --enable-cross-compile: command not found
./build_android.sh: line 46: --sysroot=/Users/jesusmartin92/Documents/android-ndk-r10d/platforms/android-9/arch-arm/: No such file or directory
./build_android.sh: line 48: --extra-cflags=-Os -fpic -marm: command not found
./build_android.sh: line 50: --extra-ldflags=: command not found`

It's like the script doesn't find the ndk folder, but I checked and the path is OK. 就像脚本找不到ndk文件夹一样,但是我检查了一下,路径确定。 The script "build_android.sh" is in the ffmpeg folder. 脚本“ build_android.sh”位于ffmpeg文件夹中。 This is the content of it: 这是它的内容:

#!/bin/bash
NDK=/Users/jesusmartin92/Documents/android-ndk-r10d
SYSROOT=$NDK/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
function build_one
{
./configure \
    --prefix=$PREFIX \
    --enable-shared \
    --disable-static \
    --disable-doc \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-avdevice \
    --disable-doc \
    --disable-symver \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --target-os=linux \
    --arch=arm \
    --enable-cross-compile \
    --sysroot=$SYSROOT \
    --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
    --extra-ldflags="$ADDI_LDFLAGS" \
    $ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
CPU=arm
PREFIX=$(pwd)/android/$CPU 
ADDI_CFLAGS="-marm"
build_one

I'm very stuck, so any idea will be well received. 我很困,所以任何想法都会受到欢迎。

Thanks 谢谢

Finally, I solved my problem. 最后,我解决了我的问题。 I put the configure command in one line and it worked!! 我把configure命令放在一行中,它起作用了!! I don't know why it was failing... 我不知道为什么会失败...

Anyway, Now I'm using this project ( https://github.com/hiteshsondhi88/ffmpeg-android-java ) so, I don't have to compile anything. 无论如何,现在我正在使用这个项目( https://github.com/hiteshsondhi88/ffmpeg-android-java ),因此,我不必编译任何东西。 I think it's the easy way to use FFMPEG in our Android applications. 我认为这是在我们的Android应用程序中使用FFMPEG的简便方法。

EDIT: I finished my project. 编辑:我完成了我的项目。 You can check my work on GitHub: https://github.com/JesusMartinAlonso/Video4Share 您可以在GitHub上检查我的工作: https : //github.com/JesusMartinAlonso/Video4Share

Try this: 尝试这个:

put the bin file of the ndk in the same directory of your ndk. 将ndk的bin文件放在ndk的同一目录中。

Enter the command prompt 输入命令提示符

go to the directory using the command prompt. 使用命令提示符转到目录。

Enter: chmod a+x android-ndk-r10d-linux-x86_64.bin then: ./android-ndk-r10d-linux-x86_64.bin 输入:chmod a + x android-ndk-r10d-linux-x86_64.bin,然后:./android-ndk-r10d-linux-x86_64.bin

(assuming you have a 64 bit machine) (假设您有一台64位计算机)

now you have the ndk. 现在您有了ndk。

go to the ndk folder then sources and extract ffmpeg-2.6 there 转到ndk文件夹,然后从中提取ffmpeg-2.6

create a file called build_android.sh containing: 创建一个名为build_android.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
######################################################
NDK=../..
PLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
function build_one
{
./configure --target-os=linux \
    --prefix=$PREFIX \
    --enable-cross-compile \
    --extra-libs="-lgcc" \
    --arch=arm \
    --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
    --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
    --nm=$PREBUILT/bin/arm-linux-androideabi-nm \
    --sysroot=$PLATFORM \
    --extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
    --disable-shared \
    --enable-static \
    --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
    --disable-everything \
    --enable-demuxer=mov \
    --enable-demuxer=h264 \
    --disable-ffplay \
    --enable-protocol=file \
    --enable-avformat \
    --enable-avcodec \
    --enable-decoder=rawvideo \
    --enable-decoder=mjpeg \
    --enable-decoder=h263 \
    --enable-decoder=mpeg4 \
    --enable-decoder=h264 \
    --enable-parser=h264 \
    --disable-network \
    --enable-zlib \
    --disable-avfilter \
    --disable-avdevice \
    $ADDITIONAL_CONFIGURE_FLAG

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.8/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

#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

enter command prompt and go to the ffmpeg-2.6 folder then enter: 输入命令提示符并转到ffmpeg-2.6文件夹,然后输入:

sudo chmod 755 build_android.sh 须藤chmod 755 build_android.sh

./build_android.sh ./build_android.sh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM