havlenapetr / FFMpeg

this is port of ffmpeg for android (this is app, but in future i will do android lib from it and then system will be able to convert videos automatically)
881 stars 420 forks source link

Unable to dlopen so #4

Open jevonbjin opened 13 years ago

jevonbjin commented 13 years ago

Hi havlenapetr,

First of all, thanks a lot for your great job, it’s really helpful. I compiled your source code successfully and run it on 2.1 emulator. But when I choose a file, the screen crashed and return the file explorer screen.

Following is log information from DDMS logcat:

09-29 02:49:12.747: DEBUG/dalvikvm(654): Trying to load lib /data/data/cz.havlena.ffmpeg.ui/lib/libjniaudio.so 0x43d0b8d8 09-29 02:49:12.778: DEBUG/dalvikvm(654): Added shared lib /data/data/cz.havlena.ffmpeg.ui/lib/libjniaudio.so 0x43d0b8d8 09-29 02:49:12.878: DEBUG/dalvikvm(654): No JNI_OnLoad found in /data/data/cz.havlena.ffmpeg.ui/lib/libjniaudio.so 0x43d0b8d8 09-29 02:49:12.997: DEBUG/dalvikvm(654): Trying to load lib /data/data/cz.havlena.ffmpeg.ui/lib/libjnivideo.so 0x43d0b8d8 09-29 02:49:13.028: INFO/dalvikvm(654): Unable to dlopen(/data/data/cz.havlena.ffmpeg.ui/lib/libjnivideo.so): Cannot load library: link_image[1721]: 30 could not load needed library 'libsurfaceflinger_client.so' for 'libjnivideo.so' (load_library[1051]: Library 'libsurfaceflinger_client.so' not found) 09-29 02:49:13.068: DEBUG/FFMpeg(654): Couldn't load lib: jnivideo - Library jnivideo not found 09-29 02:49:13.087: DEBUG/dalvikvm(654): Trying to load lib /data/data/cz.havlena.ffmpeg.ui/lib/libffmpeg_jni.so 0x43d0b8d8 09-29 02:49:13.238: INFO/dalvikvm(654): Unable to dlopen(/data/data/cz.havlena.ffmpeg.ui/lib/libffmpeg_jni.so): Cannot load library: link_image[1721]: 30 could not load needed library 'libjnivideo.so' for 'libffmpeg_jni.so' (find_library[1156]: 30 'libjnivideo.so' failed to load previously) 09-29 02:49:13.247: DEBUG/FFMpeg(654): Couldn't load lib: ffmpeg_jni - Library ffmpeg_jni not found 09-29 02:49:13.278: DEBUG/FFMpegPlayerActivity(654): Error when inicializing ffmpeg: Couldn't load native libs

I’v put libjniaudio.so libjnivideo.so libffmpeg_jni.so under folder libs/armeabi/.

I found it crashed when load native library.

FFMpeg.java.

private static boolean loadLibs() {
    if(sLoaded) {
        return true;
    }
    boolean err = false;
    for(int i=0;i<LIBS.length;i++) {
        try {
            System.loadLibrary(LIBS[i]);//crashed here –Jevon.
        } catch(UnsatisfiedLinkError e) {
            // fatal error, we can't load some our libs
            Log.d("FFMpeg", "Couldn't load lib: " + LIBS[i] + " - " + e.getMessage());
            err = true;
        }
    }
    if(!err) {
        sLoaded = true;
    }
    return sLoaded;
}

Could you please kindly give me any suggestion about this issue?

Thanks again.

havlenapetr commented 13 years ago

you must rebuild libjnivideo.so for eclair it is in my android_framework

aSpace commented 13 years ago

Hi havlenapetr, I compiled your source code successfully and run it on 2.2 emulator. logcat: D/dalvikvm( 321): Trying to load lib /data/data/cz.havlena.ffmpeg.ui/lib/libjniaudio.so 0x43e380c8

D/dalvikvm( 321): Added shared lib /data/data/cz.havlena.ffmpeg.ui/lib/libjniaudio.so 0x43e380c8

D/dalvikvm( 321): No JNI_OnLoad found in /data/data/cz.havlena.ffmpeg.ui/lib/libjniaudio.so 0x43e380c8, skipping init

D/dalvikvm( 321): Trying to load lib /data/data/cz.havlena.ffmpeg.ui/lib/libjnivideo.so 0x43e380c8

D/dalvikvm( 321): Added shared lib /data/data/cz.havlena.ffmpeg.ui/lib/libjnivideo.so 0x43e380c8

D/dalvikvm( 321): No JNI_OnLoad found in /data/data/cz.havlena.ffmpeg.ui/lib/libjnivideo.so 0x43e380c8, skipping init

D/dalvikvm( 321): Trying to load lib /data/data/cz.havlena.ffmpeg.ui/lib/libffmpeg_jni.so 0x43e380c8

D/dalvikvm( 321): Added shared lib /data/data/cz.havlena.ffmpeg.ui/lib/libffmpeg_jni.so 0x43e380c8

I/ffmpeg_onLoad( 321): loading . . .

I/ffmpeg_onLoad( 321): Registering com/media/ffmpeg/FFMpeg natives

I/ffmpeg_onLoad( 321): Registering com/media/ffmpeg/FFMpegAVFormatContext natives

I/ffmpeg_onLoad( 321): Registering com/media/ffmpeg/FFMpegAVCodecContext natives

I/ffmpeg_onLoad( 321): Registering com/media/ffmpeg/FFMpegAVRational natives

I/ffmpeg_onLoad( 321): Registering com/media/ffmpeg/FFMpegAVInputFormat natives

I/ffmpeg_onLoad( 321): Registering com/media/ffmpeg/FFMpegUtils natives

I/ffmpeg_onLoad( 321): Registering com/media/ffmpeg/FFMpegAVFrame natives

I/FFMpegPlayer-JNI( 321): register_android_media_FFMpegPlayerAndroid

I/ffmpeg_onLoad( 321): Registering com/media/ffmpeg/FFMpegPlayer natives

I/ffmpeg_onLoad( 321): loaded

I/FFMpegPlayer-JNI( 321): native_init

I/FFMpegPlayer-JNI( 321): native_setup

I/FFMpegMediaPlayer( 321): setListener

I/FFMpegPlayer-JNI( 321): set fields.context 1093023620

I/FFMpegPlayer-JNI( 321): get fields.context 1093023620

I/FFMpegPlayer-JNI( 321): setDataSource: path /sdcard/Cam26-0.mp4

I/FFMpegMediaPlayer( 321): setDataSource(/sdcard/Cam26-0.mp4)

I/ActivityManager( 60): Displayed activity cz.havlena.ffmpeg.ui/.FFMpegPlayerActivity: 2092 ms (total 2092 ms)

I/FFMpegPlayer-JNI( 321): get fields.context 1093023620

I/SurfaceWrapper( 321): registering video surface

I/SurfaceWrapper( 321): registered

I/AudioTrackWrapper( 321): registering audio track

I/AudioTrackWrapper( 321): registered

I/FFMpegPlayer-JNI( 321): get fields.context 1093023620

I/FFMpegMediaPlayer( 321): prepareVideo

I/FFMpegMediaPlayer( 321): prepareAudio

E/FFMpegMovieViewAndroid( 321): Couldn't prepare player: null

Could you please kindly give me any suggestion about this issue?

Thanks

praveenb commented 13 years ago

Hi havlenapetr, Im stuck at the same issue, getting the same error, Please let me know which files i need rebuild and how to rebuild. I searched jniaudio, jnivideo files in your android_frameworks_base bt i donot find these files. please tell me which files i need to use and rebuild in your android_frameworks_base

please give a step wise or give me any ref to follow.

Thanks

havlenapetr commented 13 years ago

here are libs and you must compile them against android source tree

https://github.com/havlenapetr/android_frameworks_base/tree/froyo/native

praveenb commented 13 years ago

Hi havlenapetr, Thank u very much for ur reply.

I downloaded the files and i did as following Im using windows xp, Cygwin, eclipse 3.4, android 1.6 api

Created a new android sample project in eclipse -> created a JNI folder in root folder->copied your native folder here -> Created Android.mk file in JNI folder and added this text include $(all-subdir-makefiles)

After doing this i compile the project in cygwin bt not getting compiled.

Please let me know 1) I did in correct way to generate libjniaudio.so and libjniviedo.so files. 2) If wrong, please let me know how to do it. 3) If right, i missed any thing here like adding any files any instructions to to the .mk file in JNI folder.

Im very beginner to this JNI. so please help me out.

Thanks for ur help

havlenapetr commented 13 years ago

you must build it against android source tree code!!!(download it from aosp and add my jni libs to it and build it all, than grab builded libs into your ndk project and build it)

praveenb commented 13 years ago

Hi havlenapetr,

Im getting this error when compiling on cygwin, after add your files to android project api 1.6.

Please let me know how to solve this issue

Praveen@vensi-1 /cygdrive/d/workspace/android/nativefiles $ /cygdrive/e/android-ndk-r5/ndk-build SharedLibrary : libjniaudio.so D:/workspace/android/nativefiles/obj/local/armeabi/objs/jniaudio/audiotrack.o: I n function AndroidAudioTrack_write': D:/workspace/android/nativefiles/jni/audiotrack.cpp:145: undefined reference to android::AudioTrack::sharedBuffer()' D:/workspace/android/nativefiles/jni/audiotrack.cpp:149: undefined reference to android::AudioTrack::sharedBuffer()' D:/workspace/android/nativefiles/jni/audiotrack.cpp:149: undefined reference to android::IMemory::size() const' D:/workspace/android/nativefiles/jni/audiotrack.cpp:153: undefined reference to android::AudioTrack::sharedBuffer()' D:/workspace/android/nativefiles/jni/audiotrack.cpp:153: undefined reference to android::IMemory::pointer() const' D:/workspace/android/nativefiles/jni/audiotrack.cpp:151: undefined reference to android::AudioTrack::sharedBuffer()' D:/workspace/android/nativefiles/jni/audiotrack.cpp:151: undefined reference to android::IMemory::size() const' D:/workspace/android/nativefiles/jni/audiotrack.cpp:146: undefined reference to android::AudioTrack::write(void const*, unsigned int)' D:/workspace/android/nativefiles/obj/local/armeabi/objs/jniaudio/audiotrack.o: I n functionAndroidAudioTrack_stop': D:/workspace/android/nativefiles/jni/audiotrack.cpp:114: undefined reference to android::AudioTrack::stop()' D:/workspace/android/nativefiles/obj/local/armeabi/objs/jniaudio/audiotrack.o: I n functionAndroidAudioTrack_unregister': D:/workspace/android/nativefiles/jni/audiotrack.cpp:130: undefined reference to android::AudioTrack::stopped() const' D:/workspace/android/nativefiles/jni/audiotrack.cpp:131: undefined reference to android::AudioTrack::stop()' D:/workspace/android/nativefiles/obj/local/armeabi/objs/jniaudio/audiotrack.o: I n function AndroidAudioTrack_reload': D:/workspace/android/nativefiles/jni/audiotrack.cpp:122: undefined reference to android::AudioTrack::reload()' D:/workspace/android/nativefiles/obj/local/armeabi/objs/jniaudio/audiotrack.o: I n function AndroidAudioTrack_flush': D:/workspace/android/nativefiles/jni/audiotrack.cpp:106: undefined reference to android::AudioTrack::flush()' D:/workspace/android/nativefiles/obj/local/armeabi/objs/jniaudio/audiotrack.o: I n function AndroidAudioTrack_set': D:/workspace/android/nativefiles/jni/audiotrack.cpp:94: undefined reference to android::AudioTrack::set(int, unsigned int, int, int, int, unsigned int, void (* )(int, void, void), void, int, android::spandroid::IMemory const&, bool)' D:/workspace/android/nativefiles/obj/local/armeabi/objs/jniaudio/audiotrack.o: I n function ~sp': D:/workspace/android/nativefiles/jni/utils/RefBase.h:331: undefined reference to android::RefBase::decStrong(void const) const' D:/workspace/android/nativefiles/obj/local/armeabi/objs/jniaudio/audiotrack.o: I n function AndroidAudioTrack_start': D:/workspace/android/nativefiles/jni/audiotrack.cpp:72: undefined reference to android::AudioTrack::start()' D:/workspace/android/nativefiles/obj/local/armeabi/objs/jniaudio/audiotrack.o: I n function AndroidAudioTrack_register': D:/workspace/android/nativefiles/jni/audiotrack.cpp:59: undefined reference to android::AudioTrack::AudioTrack()' collect2: ld returned 1 exit status make: *\ [/cygdrive/d/workspace/android/nativefiles/obj/local/armeabi/libjniaud io.so] Error 1

Thnaks

havlenapetr commented 13 years ago

here: http://source.android.com/source/download.html

praveenb commented 13 years ago

Oh Thanks havlenapetr, bt Im using Windows xp,

In that link i see, "To build the Android source files, you will need to use Linux or Mac OS. Building under Windows is not currently supported."

Im not sure abt how i can build aosp files on windows xp.

Actucally i need to convert .aac format and play on any android version device. Hoping any substitute will be there to implement audio and video codecs.

If you have any idea please let me know.

Thanks for your help

havlenapetr commented 13 years ago

sorry I am not windows user

alexcohn commented 13 years ago

Hi praveen,

I hope you already resolved your problem. If you are still curious, note that you do not need to build AOSP to compile these jniaudio and jnivideo libraries. You need the header files, namely

for audio: $(PLATFORM_ROOT)/frameworks/base/include \ $(PLATFORM_ROOT)/frameworks/base/native/include \ $(PLATFORM_ROOT)/system/core/include

for video: $(PLATFORM_ROOT)/external/skia/src/core \ $(PLATFORM_ROOT)/external/skia/include/core \ $(PLATFORM_ROOT)/frameworks/base/include \ $(PLATFORM_ROOT)/frameworks/base/native/include

Also, you need the libraries for your platform. You can pull them with adb from your device' /system/lib directory.

For audio: LOCAL_LDLIBS := -llog -ldl -L$(PLATFORM_LIBS) -lbinder -lmedia -lutils

For video: LOCAL_LDLIBS := -llog -L$(PLATFORM_LIBS) -lskia -lsurfaceflinger_client -lutils

praveenb commented 13 years ago

Hi alex,

Actually due to lack of support i left ffmpeg support project and moved to another project. I'll sure get back to you if i need any further support..

Thankyou for your reply. :)

On Thu, May 12, 2011 at 3:55 PM, alexcohn < reply@reply.github.com>wrote:

Hi praveen,

I hope you already resolved your problem. If you are still curious, note that you do not need to build AOSP to compile these jniaudio and jnivideo libraries. You need the header files, namely

for audio: $(PLATFORM_ROOT)/frameworks/base/include \ $(PLATFORM_ROOT)/frameworks/base/native/include \ $(PLATFORM_ROOT)/system/core/include

for video: $(PLATFORM_ROOT)/external/skia/src/core \ $(PLATFORM_ROOT)/external/skia/include/core \ $(PLATFORM_ROOT)/frameworks/base/include \ $(PLATFORM_ROOT)/frameworks/base/native/include

Also, you need the libraries for your platform. You can pull them with adb from your device' /system/lib directory.

For audio: LOCAL_LDLIBS := -llog -ldl -L$(PLATFORM_LIBS) -lbinder -lmedia -lutils

For video: LOCAL_LDLIBS := -llog -L$(PLATFORM_LIBS) -lskia -lsurfaceflinger_client -lutils

Reply to this email directly or view it on GitHub: https://github.com/havlenapetr/FFMpeg/issues/4#comment_1145707

With regards, B.Praveen

ghost commented 11 years ago

Hey.. can you please tell me how to rebuild it for android api 14. i am getting error "Couldn't load navtive libs." and "loadLibrary returned null"