我的目标是构建ffmpeg static libraries
以便我可以将它们与jni一起使用并直接调用ffmpeg中定义的函数将一系列图像编码为h264视频流,并使用android 2.3.6中的GLSurfaceVIew在屏幕上呈现它
使用https://www.ffmpeg.org/doxygen/0.6/api-example_8c-source.html我知道通过拥有所需的.so文件和标题,我可以做到这一点。
我跟随Android NDK & FFMPEG build和其他许多人。无处不在我发现了roman10的构建脚本。
我使用Ubunthu 12.0.4 LTS与android-ndk-r9和ffmpeg-0.10源代码!
以下是我使用的构建脚本!
NDK=~/android-ndk-r9
PLATFORM=$NDK/platforms/android-8/arch-arm/
#PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.7/prebuilt/windows
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86
function build_one
{
./configure --target-os=linux \
--prefix=$PREFIX \
--enable-cross-compile \
--extra-libs="-lgcc" \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc-4.8 \
--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 \
--disable-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 -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 v7vfpv3
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one
当我运行脚本(test_build.sh
)时,我得到了
Unknown option "".
See ./configure --help for available options.
./test_build.sh: line 34: --nm=/home/user/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-nm: No such file or directory
CC ffmpeg.o
CC cmdutils.o
CC libavdevice/alldevices.o
CC libavdevice/avdevice.o
CC libavdevice/dv1394.o
ffmpeg.c: In function âopt_input_fileâ:
ffmpeg.c:3698:9: warning: âloop_inputâ is deprecated (declared at libavformat/avformat.h:1049) [-Wdeprecated-declarations]
ffmpeg.c: In function âopt_output_fileâ:
ffmpeg.c:4483:9: warning: âloop_outputâ is deprecated (declared at libavformat/avformat.h:1025) [-Wdeprecated-declarations]
CC libavdevice/fbdev.o
CC libavdevice/lavfi.o
CC libavdevice/oss_audio.o
CC libavdevice/v4l2.o
CC libavfilter/af_aconvert.o
libavfilter/af_aconvert.c:53:5: warning: function declaration isnât a prototype[-Wstrict-prototypes]
libavfilter/af_aconvert.c:105:5: warning: function declaration isnât a prototype[-Wstrict-prototypes]
CC libavfilter/af_aformat.o
CC libavfilter/af_amerge.o
CC libavfilter/af_anull.o
CC libavfilter/af_aresample.o
CC libavfilter/af_ashowinfo.o
CC libavfilter/af_asplit.o
CC libavfilter/af_astreamsync.o
CC libavfilter/af_earwax.o
CC libavfilter/af_pan.o
CC libavfilter/af_silencedetect.o
CC libavfilter/af_volume.o
CC libavfilter/allfilters.o
CC libavfilter/asink_anullsink.o
libavfilter/af_volume.c: In function âfilter_samplesâ:
./libavutil/arm/intmath.h:104:5: error: invalid 'asm': invalid operand code 'R'
./libavutil/arm/intmath.h:104:5: error: invalid 'asm': invalid operand code 'R'
make: *** [libavfilter/af_volume.o] Error 1
make: *** Waiting for unfinished jobs....
./test_build.sh: line 61: /home/user/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-ar: cannot execute binary file
./test_build.sh: line 62: /home/user/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-ld: cannot binary file
我怎样才能让它发挥作用,或者我是以错误的方式尝试?任何帮助都是适当的!!
如果有人指出我出错的原因。我不知道为什么nm显示错误,虽然它存在于指定的路径上! 谢谢