2014-02-27 334 views
7

我已經看到很多關於FFmpeg和在Android中使用FFmpeg的帖子,但是我發現這些帖子大部分都是針對FFmpeg或Android NDK的舊版本。我能從https://github.com/mconf/android-ffmpeg得到結果,其中包括文件:「libavcodec.so」,「libavformat.so」,「libavutil.so」,「libswscale.so」。但是,僅僅將這些文件添加到我的項目似乎不足以使用FFmpeg。 (我遵循https://stackoverflow.com/a/21773572/1877798作爲參考指南)。有可能是我在我的項目中配置這些文件時做了錯誤的事情,或者我在構建Android的FFmpeg時做了一些錯誤。 (應該有更多的文件嗎?)Android - 集成ffmpeg和android-ndk-r9c

我想知道是否有最新的指南,建設或整合FFmpeg在Android項目。我正在使用FFmpeg(截至2/27/14)和Android NDK 9c。 如果沒有,是否有人對其他庫有其他建議?我正嘗試拍攝一組圖像文件並以編程方式創建視頻/動畫gif。

謝謝! :-)


~~編輯~~

我發現http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/comment-page-4/和幾個人在GitHub上找到。然而,他們似乎都在努力構建FFmpeg。我使用的是Mac OS X

這裏是我的腳本:

#!/bin/bash 
NDK=/Downloads/android-ndk-r9c 
SYSROOT=$NDK/platforms/android-18/arch-arm/ 
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64 
# Note: Change the TOOLCHAIN to match that available for your host system. 
# darwin-x86_64 is for Mac OS X, but you knew that. 
function build_one 
{ 
./configure \ 
    --prefix=$PREFIX \ 
    --enable-shared \ 
    --disable-static \ 
    --disable-doc \ 
    --disable-programs \ 
    --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 

這裏是日誌:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-  dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 
/Downloads/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc is unable to create an executable file. 
C compiler test failed. 

If you think configure made a mistake, make sure you are using the latest 
version from Git. If the latest version fails, report the problem to the 
[email protected] mailing list or IRC#ffmpeg on irc.freenode.net. 
Include the log file "config.log" produced by configure as this will help 
solving the problem. 
Makefile:2: config.mak: No such file or directory 
Makefile:48: /common.mak: No such file or directory 
Makefile:91: /libavutil/Makefile: No such file or directory 
Makefile:91: /library.mak: No such file or directory 
Makefile:168: /doc/Makefile: No such file or directory 
Makefile:169: /tests/Makefile: No such file or directory 
make: *** No rule to make target `/tests/Makefile'. Stop. 
Makefile:2: config.mak: No such file or directory 
Makefile:48: /common.mak: No such file or directory 
Makefile:91: /libavutil/Makefile: No such file or directory 
Makefile:91: /library.mak: No such file or directory 
Makefile:168: /doc/Makefile: No such file or directory 
Makefile:169: /tests/Makefile: No such file or directory 
make: *** No rule to make target `/tests/Makefile'. Stop. 
Makefile:2: config.mak: No such file or directory 
Makefile:48: /common.mak: No such file or directory 
Makefile:91: /libavutil/Makefile: No such file or directory 
Makefile:91: /library.mak: No such file or directory 
Makefile:168: /doc/Makefile: No such file or directory 
Makefile:169: /tests/Makefile: No such file or directory 
make: *** No rule to make target `/tests/Makefile'. Stop. 

回答

0

試試這一個,這是最好到目前爲止,我已經使用:https://github.com/bbcallen/ijkplayer

+0

你能幫我在那裏:如何使用ijkplayer庫]( http://stackoverflow.com/questions/24594674/how-to-use-ijkplayer-library) – MAY3AM

0

我有同樣的錯誤。

「生成文件:2:config.mak:沒有這樣的文件或目錄生成文件 :48:/common.mak:沒有這樣的文件或目錄生成文件 :91:/ libavutil /生成文件:沒有這樣的文件或目錄生成文件 :91:/library.mak:沒有這樣的文件或目錄 Makefile:168:/ doc/Makefile:沒有這樣的文件或目錄 Makefile:169:/ tests/Makefile:沒有這樣的文件或目錄 make:*** No規則使目標`/ tests/Makefile'停止。「

請檢查您的腳本內的腳本路徑是否正確。即:'/下載/ Android的NDK-R9C /工具鏈/ ARM-Linux的androideabi-4.8 /預建/達爾文-x86_64的/」

我認爲它實際上是 「$ HOME /下載」

也使確定你正在運行「.../android-ndk-r9c/sources/FFMPEG /」目錄下的腳本

0

你需要修復你的NDK路徑不正確 可能是:NDK =/user //下載/ Android的NDK-R9C

而且在瀏覽器中,你想檢查爲:

file:/// user/xyz/Downloads/android-ndk-r9c

if valid然後打開「android-ndk-r9c」文件夾。當你成功後,把它放在你的NDK路徑上並構建。

0

我使用的Android NDK r10e與MAC的ffmpeg 2.7.1和1.2.0 YASM(所有下載的文件夾)OS X

#!/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) 
# set $CPU and $OPTIMIZE_CFLAGS 
# call build_one 

NDK=$Users/samavesh/Downloads/android-ndk-r10e 
SYSROOT=$NDK/platforms/android-9/arch-arm/ 
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-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" \ 
--enable-parsers \ 
--enable-encoders \ 
--enable-decoders \ 
--disable-muxers \ 
--enable-demuxers \ 
--enable-swscale \ 
--disable-ffmpeg \ 
--disable-ffplay \ 
--disable-ffprobe \ 
--disable-ffserver \ 
--enable-network \ 
--enable-indevs \ 
--disable-bsfs \ 
--enable-filters \ 
--enable-protocols \ 
--enable-asm \ 
$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 \ 
-Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so \ 
libavcodec/libavcodec.a libavdevice/libavdevice.a libavfilter/libavfilter.a \ 
libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a \ 
libswresample/libswresample.a -lc -lm -lz -ldl -llog \ 
--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 
+0

你可以通過添加一些評論或解釋來豐富你的答案! – AADProgramming