wseemann / FFmpegMediaPlayer

FFmpegMediaPlayer can be used to control playback of audio/video files and streams.
676 stars 200 forks source link

Using FFmpegMediaPlayer with FFmpegMediaMetadataRetriever #83

Open vxhviet opened 8 years ago

vxhviet commented 8 years ago

Hi @wseemann, sorry to bother you again. I didn't realize you has a Media Player built on FFmpeg so I would like to give it a try.

I use the gradle build for FFMMR:

dependencies {
    compile 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.8'
}

and use the FFMP prebuilt from here (your download link in the README is broken). I get a couple of duplicated ffmpeg libraries so I add the following to build.gradle:

android {
    packagingOptions {
        exclude 'lib/armeabi-v7a/libavcodec.so'
        exclude 'lib/armeabi-v7a/libswscale.so'
        exclude 'lib/armeabi-v7a/libavformat.so'
        exclude 'lib/armeabi-v7a/libavutil.so'

        exclude 'lib/x86/libavcodec.so'
        exclude 'lib/x86/libavformat.so'
        exclude 'lib/x86/libavutil.so'
        exclude 'lib/x86/libswscale.so'

        exclude 'lib/x86_64/libavformat.so'
        exclude 'lib/x86_64/libswscale.so'
        exclude 'lib/x86_64/libavutil.so'
        exclude 'lib/x86_64/libavcodec.so'

        exclude 'lib/armeabi/libavformat.so'
        exclude 'lib/armeabi/libavutil.so'
        exclude 'lib/armeabi/libswscale.so'
        exclude 'lib/armeabi/libavcodec.so'

        exclude 'lib/mips/libavcodec.so'
        exclude 'lib/mips/libswscale.so'
        exclude 'lib/mips/libavutil.so'
        exclude 'lib/mips/libavformat.so'
    }
}

But i still get the java.lang.UnsatisfiedLinkError. Is there anything I can do to solve this problem?

Thank you so much for your time.

vxhviet commented 8 years ago

I try to run FFMP without FFMMR and get this stack trace:

D/MainActivity: onScanCompleted
V/FFmpegMediaPlayer-JNI: native_init
V/FFmpegMediaPlayer-JNI: native_setup
V/FFmpegMediaPlayer-JNI: setDataSourceFD: fd 32
E/libOpenSLES: pAudioSrc: channelMask=0x3 numChannels=1
W/libOpenSLES: Leaving Engine::CreateAudioPlayer (SL_RESULT_PARAMETER_INVALID)
A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 2536 (.viet.myappdemo)

Is this library still active?

wseemann commented 8 years ago

What are you trying to play? It appears to be a bug.

vxhviet commented 8 years ago

just a typical Android video, should be the same one as the one I sent in this

vxhviet commented 8 years ago

Sorry, this seem like a problem on my part, I'll try to investigate more before coming back.

wseemann commented 8 years ago

The following lines indicate there is an issue creating the OpenSLES audio engine.

E/libOpenSLES: pAudioSrc: channelMask=0x3 numChannels=1 W/libOpenSLES: Leaving Engine::CreateAudioPlayer (SL_RESULT_PARAMETER_INVALID)

It's not an issue on your end, it's a bug. I'll take a look when I get a chance.

wseemann commented 8 years ago

You can use both libraries now, I created FFmpegMediaBundle.

vxhviet commented 8 years ago

Wow you are really dedicated, I'll try and and come back in a minute. Thank you so much for your time.

vxhviet commented 8 years ago

Sorry, my bad. It seems like Android Studio still using my old code base why trying FFmpegMediaBundle so I think it's working (super annoying Instant Run).

After re checking many times, I still get this:

W/art: Suspending all threads took: 10.097ms
E/libOpenSLES: pAudioSrc: channelMask=0x3 numChannels=1
W/libOpenSLES: Leaving Engine::CreateAudioPlayer (SL_RESULT_PARAMETER_INVALID)
A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 21415 (.viet.myappdemo)

so I guess the bug is still hanging around?

vxhviet commented 8 years ago

Hello again @wseemann, I understand you still haven't had time for this project yet. However, I would like to put my issue here, hopefully it will save you some development time.

Basically what I'm trying to do is using FFmpegMediaPlayer to seek through a local video via the seekTo(int position) method. The video is not actually played, but instead being scrubbed through like this.

I've tried a lot of player before but they either very inaccurate with seeking or very slow. I understand it takes sometime to decode the frame from the keyframe which means stuttering and slowness.

What I'm looking for is the Input Seeking of ffmpeg and hopefully it will give me smoother scrubbing. Could you please implement this seeking method in the future release of FFmpegMediaPlayer and if possible, changing seekTo(int position) to seekTo(long millisecond) for better precision.

Thank you so much for your time.

vxhviet commented 8 years ago

Dear @wseemann, I saw you have a recent commit fixing "broken pipe protocol" but still haven't seen any release since then.

Would you mind providing a new prebuilt AAR for this commit as it is the only way I can successfully use FFmpegMP in Android Studio. I've try to build this before but without much success.

Thanks again for your time.