Windows 中的 FFMPEG for android 无法成功编译

Posted

技术标签:

【中文标题】Windows 中的 FFMPEG for android 无法成功编译【英文标题】:FFMPEG for android in Windows not successfully compile 【发布时间】:2014-09-27 18:50:09 【问题描述】:

我正在尝试在 Windows 8.1 中为 android 编译 FFMPEG,但在 build_android.sh 的第 32 行出现错误

./build_android.sh:第 32 行:语法错误:文件意外结束

当我在 cygwin 中执行命令时

chmod +x build_android.sh

./build_android.sh

如果您知道在 windows 中为 android 编译 ffmpeg 的步骤以及如何在 android 中使用 ffmpeg,请回复我。

我在引用 . http://www.packtpub.com/sites/default/files/downloads/Developing_Multimedia_Applications_with_NDK.pdf ,

https://trac.ffmpeg.org/wiki/CompilationGuide/Android 和

http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9

build_android.sh

#!/bin/bash
NDK=E:/android-ndk-r9d
SYSROOT=$NDK/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/windows
function build_one  ./configure \
--prefix=$PREFIX \
--disable-shared \
--enable-static \
--disable-doc \
--enable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--enable-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

【问题讨论】:

【参考方案1】:
    检查行尾(使用 dos2unix 修复) $ADDITIONAL_CONFIGURE_FLAG - 检查此变量是否不包含未封闭的配额/括号。

【讨论】:

【参考方案2】:

您可以将其用作 build_android.sh,我对其进行了测试,它对我有效

#!/bin/bash
NDK=D:/android/ndk/android-ndk-r10d
SYSROOT=$NDK/platforms/android-8/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows
function build_one

./configure \
--prefix=$PREFIX \
--disable-shared \
--enable-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

您还需要运行以下命令:

dos2unix build_android.sh
chmod +x build_android.sh
./build_android.sh

【讨论】:

【参考方案3】:

改变

make instal 

make install

make install; 

因为这样,您将 作为 make 的第二个参数传递,并且您的函数 build_one 没有关闭

编辑

你可以试试这个吗?

NDK=E:/android-ndk-r9d
SYSROOT=$NDK/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/windows
CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"
./configure \
--prefix=$PREFIX \
--disable-shared \
--enable-static \
--disable-doc \
--enable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--enable-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

【讨论】:

./configure: line 9: $'\r': command not found ): No such file or directoryg: setlocale: LC_ALL: cannot change locale (C': not a valid identifierort: @987654329 @$'\r'' '/configure:第 17 行:`try_exec() 您必须使用 unix 行尾 (\n) 保存脚本,而不是 Windows/DOS 行尾 (\r\n)。 错误信息说 ./configure 有 DOS 行尾,检查这个文件。 如何查看是否以DOS行结尾? 让我们continue this discussion in chat。

以上是关于Windows 中的 FFMPEG for android 无法成功编译的主要内容,如果未能解决你的问题,请参考以下文章