DJI-Mobile-SDK-Tutorials / Android-VideoStreamDecodingSample

This sample project demonstrates how to use FFmpeg for video frame parsing and to use MediaCodec for hardware decoding on DJI Products.
MIT License
170 stars 81 forks source link

Re-Compile JNI DJIVIDEOSTREAMDECODE #5

Closed lillogoal closed 6 years ago

lillogoal commented 7 years ago

Hello to all, I'm trying to re-compile the source C ++, using the latest Android NDK builder. The code is posted here: https://github.com/DJI-Mobile-SDK-Tutorials/Android-VideoStreamDecodingSample/tree/master/android-videostreamdecodingsample/jni

I have this problem, this is the log:

[armeabi-v7a] Compile thumb : djivideojni <= dji_video_jni.c jni/dji_video_jni.c:65:51: warning: passing 'uint8_t ' (aka 'unsigned char ') to parameter of type 'const jbyte ' (aka 'const signed char ') converts between pointers to integer types with different sign [-Wpointer-sign] (*env)->SetByteArrayRegion(env, jarray, 0, size, buf); ^~~ 1 warning generated. [armeabi-v7a] Prebuilt : libffmpeg.so <= jni/ [armeabi-v7a] SharedLibrary : libdjivideojni.so D:/Users/Lorenzo/AppData/Local/Android/sdk/ndk-bundle/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: error: ./obj/local/armeabi-v7a/libffmpeg.so:1:9: syntax er ror, unexpected STRING D:/Users/Lorenzo/AppData/Local/Android/sdk/ndk-bundle/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: error: ./obj/local/armeabi-v7a/libffmpeg.so: not an object or archive jni/dji_video_jni.c:43: error: undefined reference to 'av_register_all' jni/dji_video_jni.c:45: error: undefined reference to 'av_codec_next' jni/dji_video_jni.c:78: error: undefined reference to 'avcodec_register_all' jni/dji_video_jni.c:79: error: undefined reference to 'av_register_all' jni/dji_video_jni.c:82: error: undefined reference to 'avcodec_find_decoder' jni/dji_video_jni.c:83: error: undefined reference to 'avcodec_alloc_context3' jni/dji_video_jni.c:84: error: undefined reference to 'av_parser_init' jni/dji_video_jni.c:97: error: undefined reference to 'avcodec_open2' jni/dji_video_jni.c:103: error: undefined reference to 'av_frame_alloc' jni/dji_video_jni.c:127: error: undefined reference to 'av_init_packet' jni/dji_video_jni.c:132: error: undefined reference to 'av_parser_parse2' jni/dji_video_jni.c:165: error: undefined reference to 'av_free_packet' jni/dji_video_jni.c:223: error: undefined reference to 'avcodec_close' jni/dji_video_jni.c:227: error: undefined reference to 'av_free' jni/dji_video_jni.c:228: error: undefined reference to 'av_free' jni/dji_video_jni.c:229: error: undefined reference to 'av_parser_close' clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [obj/local/armeabi-v7a/libdjivideojni.so] Error 1

pisarik commented 7 years ago

I have stepped into the same problem and found a solution. This happened, because I didn't notice in readme the important section.

I noticed that libffmpeg.so takes only 1KB of memory. Meanwhile original libffmpeg.so takes about 60MB of memory and therefore it was stored with help of special module . That is why your linking failed.

In that case you can complete linking without dipping into git lfs (but I am sure, that it is pretty simple). You can just download this original libffmpeg.so and replace the "placeholder" libffmpeg.so which located in app/jni

Also don't forget to change package names in dji_video_jni.c functions, which tagged as JNI_EXPORT

lillogoal commented 7 years ago

@pisarik thank you so much :)

giannisergente commented 7 years ago

Hi @lillogoal, we have the same issue (https://github.com/DJI-Mobile-SDK-Tutorials/Android-VideoStreamDecodingSample/issues/12). Did you solve also for arm64-v8a e x86 ABI? Because in those cases compilation fails :(

dji-dev commented 6 years ago

Will go ahead and close this ticket as current version should have a fix for v8a and x86 already. Please feel free to reopen if the problem still exists. Thanks!