tanersener / mobile-ffmpeg

FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit.
https://tanersener.github.io/mobile-ffmpeg
GNU General Public License v3.0
3.85k stars 787 forks source link

Multiple Ffmpeg .so file #522

Closed PrinceVergil closed 4 years ago

PrinceVergil commented 4 years ago

Description I am using exoplayer-extension-ffmpeg And when i try to add mobile-ffmpeg More than one file was found with OS independent path to resolve this i have added.

packagingOptions {
        pickFirst '**/*.so'
   }

now code get compiled and runs but when it comes to execute int rc = FFmpeg.execute(cmd); it throws this error

   Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "av_rdft_init" referenced by "/data/app/com.example.client2-7zGqB9WZi2kzEY7AcZLOWg==/base.apk!/lib/arm64-v8a/libavfilter.so"...
        at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
        at java.lang.System.loadLibrary(System.java:1669)
        at com.arthenica.mobileffmpeg.Config.<clinit>(Config.java:147)
        at com.arthenica.mobileffmpeg.Config.ffmpegExecute(Config.java:637)
        at com.arthenica.mobileffmpeg.FFmpeg.execute(FFmpeg.java:68)
        at com.arthenica.mobileffmpeg.FFmpeg.execute(FFmpeg.java:129)
        at com.example.client2.MainActivity$getVideoFFmpg.doInBackground(MainActivity.java:449)
        at android.os.AsyncTask$2.call(AsyncTask.java:333)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:764) 

is there any way to resolve this?

markkimsal commented 4 years ago

you need to write individual pickFirst lines or get the build straightened out to where you don't have duplicate so files.

packagingOptions {
     pickFirst 'lib/armeabi/libavdevice.so' 
     pickFirst 'lib/armeabi-v7a/libavdevice.so' 
     pickFirst 'lib/arm64-v8a/libavdevice.so' 
     pickFirst 'lib/x86/libavdevice.so' 
     pickFirst 'lib/x86_64/libavdevice.so'
     //etc ....

you might be able to try

  packagingOptions {
       pickFirst '**/libavdevice.so' 
       pickFirst '**/libavformat.so' 
       pickFirst '**/libavcodec.so' 
       //etc ....
PrinceVergil commented 4 years ago

@markkimsal still issue of dlopen is there i temporary fixed it with ndk { abiFilters "armeabi-v7a", "x86","x86_64" }

alexcohn commented 4 years ago

The rules of Google Play Store require that your APK includes arm64-v8a binaries, but if you don't intend to publish your app, it's fine to keep armeabi-v7a libraries only. Consider using NEON for better performance.

The name clash between mobile-ffmpeg and exoplayer is not an innocent one, and -neon libraries resolve this problem at the expense of actually having almost duplicate binaries in your APK.

The best strategy if you must include both libraries, would be to use the mobile-ffmpeg shared objects for your expolayer. Make sure that you enable the relevant decoders when you run android.sh. After this is ready, you can simply copy the *.so files from prebuilt/ffmpeg to $FFMPEG_EXT_PATH/ffmpeg/android-libs instead of running build_ffmpeg.sh. Now, packagingOptions { pickFirst '**/*.so' } will be safe.

PrinceVergil commented 4 years ago

@alexcohn thanks for commenting. yes i need to push app to store. ill try you're suggestion

PrinceVergil commented 4 years ago

@alexcohn Thanks Solved it as you instructed.