我到底要怎么办:访问 ffmpeg.c 文件来修改 INT主(INT ARGC,字符** argv的)函数的 JNI 并通过的ffmpeg的命令字符串。
What i exactly want to-do : Access the ffmpeg.c file to modify the int main(int argc, char **argv) function to JNI and passing the command of ffmpeg as string.
我试图端口的ffmpeg C库到Android(ARM处理器)。我跟着以下不同的方法来做到这一点。
I have tried to port ffmpeg C library to android(ARM processor). I followed following different ways to do this.
第一次尝试:用官方的ffmpeg的安装文档。操作步骤如下:
1st Try: using official ffmpeg installation documentation. Steps as follows
一)混帐混帐克隆://source.ffmpeg.org/ffmpeg.git的ffmpeg
a) git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
二)阅读INSTALL文件。
b) Read the INSTALL file.
C)下载X264库,并建立使用 build_x264.sh 它建立成功。
c) Download x264 library and build by using build_x264.sh which build successfully.
NDK=/home/nav/Work/android/ndk
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt
PLATFORM=$NDK/platforms/android-8/arch-arm
PREFIX=/home/nav/28ffmpeg/android-ffmpeg
./configure --prefix=$PREFIX --enable-static --enable-pic --disable-asm --disable-cli --host=arm-linux --cross-prefix=$PREBUILT/linux-x86/bin/arm-linux-androideabi- --sysroot=$PLATFORM
make
sudo make install
sudo ldconfig
D)然后,我从(http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2)通过构建它的 build_android.sh
d) Then i download ffmpeg library from (http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2) build it by using build_android.sh
#!/bin/bash
NDK=/home/nav/Work/android/ndk
PLATFORM=$NDK/platforms/android-8/arch-arm
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
PREFIX=/home/nav/28ffmpeg/android-ffmpeg
function build_one
{
./configure --target-os=linux --prefix=$PREFIX \
--enable-cross-compile \
--enable-runtime-cpudetect \
--disable-asm \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--disable-stripping \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--enable-nonfree \
--enable-version3 \
--disable-everything \
--enable-gpl \
--disable-doc \
--enable-avresample \
--enable-demuxer=rtsp \
--enable-muxer=rtsp \
--disable-ffplay \
--disable-ffserver \
--enable-ffmpeg \
--disable-ffprobe \
--enable-libx264 \
--enable-encoder=libx264 \
--enable-decoder=h264 \
--enable-protocol=rtp \
--enable-hwaccels \
--enable-zlib \
--disable-devices \
--disable-avdevice \
--extra-cflags="-I/home/android-ffmpeg/include -fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a" \
--extra-ldflags="-L/home/android-ffmpeg/lib"
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 -L$PREFIX/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavfilter/libavfilter.a libavresample/libavresample.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog -lx264 --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
}
build_one
E)最初,它完美的作品。但是,错误后来了:
libavformat/libavformat.a(log2_tab.o):(.rodata+0x0): multiple definition of `ff_log2_tab'
libavcodec/libavcodec.a(log2_tab.o):(.rodata+0x0): first defined here
libavutil/libavutil.a(log2_tab.o):(.rodata+0x0): multiple definition of `ff_log2_tab'
libavcodec/libavcodec.a(log2_tab.o):(.rodata+0x0): first defined here
build_android.sh: 48: build_one: not found
结果: *的 libffmpeg.so 的*找不到
第二个尝试:然后我按照http://dl.dropbox.com/u/22605641/ffmpeg_android/main.html->构建
2nd Try: Then I follow steps in http://dl.dropbox.com/u/22605641/ffmpeg_android/main.html-> Builds
一)我下载了pre-生成的 libffmpeg.so 从上面的链接。
a) I downloaded Pre-Build libffmpeg.so from above link.
b)增加 libffmpeg.so 为库/ armeabi /
c)使 Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg
LOCAL_SRC_FILES := libffmpeg.so
include $(PREBUILT_SHARED_LIBRARY)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := main
LOCAL_STATIC_LIBRARIES += ffmpeg
LOCAL_SRC_FILES := ffmpeg-test.c
include $(BUILD_SHARED_LIBRARY)
D)然后,我做的所有NDK的建立和all.Copy ffmpeg.c 从库中的的ffmpeg-test.c的通过改变它的 INT主功能,我的 JNI 载体作用,并包括所有必要的包含文件。
d) Then I do all ndk set up and all.Copy ffmpeg.c from library to ffmpeg-test.c by changing its int main function to my JNI functin and include all necessary include files.
错误:
控制台:
/home/nav/Work/android/ndk/ndk-build all
Prebuilt : libffmpeg.so <= jni/
Install : libffmpeg.so => libs/armeabi/libffmpeg.so
Compile thumb : main <= ffmpeg-test.c
jni/ffmpeg-test.c: In function 'print_report':
jni/ffmpeg-test.c:1139:94: warning: incompatible implicit declaration of built-in function 'log2' [enabled by default]
SharedLibrary : libmain.so
/home/nav/Work/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/main/ffmpeg-test.o: in function check_keyboard_interaction:jni/ffmpeg-test.c:2496: error: undefined reference to 'qp_hist'
和许多其他未定义的引用.....
and many other undefined references.....
告诉我在哪里,我得到错误的。急需.....
Tell me where I am getting wrong. Needed Urgently.....
https://github.com/ guardianproject / Android的ffmpeg的
看这个项目的Git上进行更改的线索ffmpeg.c.main() 我认为,建立该项目将正常工作的NDK中的自述文件中提到的释放。
look at this project on git for clues on making changes to 'ffmpeg.c.main()' I believe that the build for this project will work fine on release of NDK mentioned in the readme.
请注意:
您应该花一些时间在NDK发行版的所有文档文件,好让你明白是怎么制作作品。
you should spend some time with all the doc files in the NDK distro so that u understand how the make works.
主()函数的退出条件,通常需要稍微为Android JNI改变。
The exit condition of the 'main()' function usually needs to be altered slightly for android JNI .