magiclen / FFmpeg-CLI-For-Android

Now, you can edit audios and videos by using Command Line Interface for FFmpeg.
https://magiclen.org/ffmpeg-android/
24 stars 7 forks source link

How to bundle the compiled ffmpeg into apk and execute it according to target cpu? #6

Closed mortyccp closed 7 years ago

mortyccp commented 8 years ago

Would you mind give me insight on how to do that?

magiclen commented 8 years ago

You can read this article

https://magiclen.org/android-ffmpeg/

mortyccp commented 8 years ago

I have follow the same procedure, but File fileBin = new File(fileBinDir, "libffmpeg.so"); just give me null. Also, File fileBinDir = new File(activity.getFilesDir().getParentFile(), "lib"); does not exits too.

magiclen commented 8 years ago

Please paste or push your full code on GitHub

mortyccp commented 8 years ago

Repo

error message

08-10 13:07:31.365 11989-11989/com.morty.ffmpegclisample W/System: ClassLoader referenced unknown path: /data/app/com.morty.ffmpegclisample-1/lib/arm64
08-10 13:07:31.380 11989-11989/com.morty.ffmpegclisample W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
08-10 13:07:31.413 11989-11989/com.morty.ffmpegclisample W/System.err: java.io.IOException: Error running exec(). Command: [libffmpeg.so -version] Working Directory: /data/user/0/com.morty.ffmpegclisample/lib Environment: [ANDROID_ROOT=/system, LD_PRELOAD=libNimsWrap.so, ANDROID_BOOTLOGO=1, EXTERNAL_STORAGE=/sdcard, SYSTEMSERVERCLASSPATH=/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar, ANDROID_SOCKET_zygote=12, PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin, ANDROID_DATA=/data, ANDROID_ASSETS=/system/app, ASEC_MOUNTPOINT=/mnt/asec, BOOTCLASSPATH=/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/apache-xml.jar:/system/framework/org.apache.http.legacy.boot.jar:/system/framework/tcmiface.jar:/system/framework/WfdCommon.jar:/system/framework/oem-services.jar:/system/framework/com.qti.dpmframework.jar:/system/framework/dpmapi.jar:/system/framework/com.qti.location.sdk.jar:/system/framework/qcmediaplayer.jar, ANDROID_PROPERTY_WORKSPACE=11,0, ANDROID_STORAGE=/storage]
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at java.lang.ProcessManager.exec(ProcessManager.java:211)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at java.lang.ProcessBuilder.start(ProcessBuilder.java:195)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at com.morty.ffmpegclisample.MainActivity.onCreate(MainActivity.java:21)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at android.app.Activity.performCreate(Activity.java:6285)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at android.app.ActivityThread.access$900(ActivityThread.java:154)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at android.os.Looper.loop(Looper.java:234)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5526)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err: Caused by: java.io.IOException: No such file or directory
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at java.lang.ProcessManager.exec(Native Method)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:     at java.lang.ProcessManager.exec(ProcessManager.java:209)
08-10 13:07:31.414 11989-11989/com.morty.ffmpegclisample W/System.err:  ... 14 more
magiclen commented 8 years ago

Your FFmpeg file name is not the same as the name in your code

mortyccp commented 8 years ago

Okay, I have fixed that and pushed. But still the same result. Caused by: java.io.IOException: No such file or directory I think this error said, the file or directory is not exits. It there other step I am missing?

magiclen commented 8 years ago

Yes, I think you should use absolute path for the command and make sure you have the reading and execution permission for your FFmpeg file.

mortyccp commented 8 years ago

In your article, you said putting those files under libs folder will work. Why its not working in my cases? I wonder are those libffmepg have got copied into the apk. How you do that in your own app?

magiclen commented 8 years ago

Just the same way. But I use my own library MagicCommand

mortyccp commented 8 years ago

OK. I think I will fix the file not exits problem first.