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.87k stars 791 forks source link

Lib crash for some commands saying java.lang.UnsatisfiedLinkError: dlopen failed: library "libavfilter.so" not found #605

Closed codes29 closed 3 years ago

codes29 commented 3 years ago

Description When executing command to concat videos, the library produces crash saying java.lang.UnsatisfiedLinkError: dlopen failed: library "libavfilter.so" not found. So, I analyzed the apk, but this library "libavfilter.so" is present in there. Then why is this not able to open the library.

Expected behavior It should execute the command successfully

Current behavior App crashes with runtime excption

Screenshots If applicable, add screenshots to help explain your problem.

Logs AndroidRuntime: FATAL EXCEPTION: AsyncTask #11 Process: com.app.whoop.dev, PID: 12693 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:354) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) 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) Caused by: java.lang.NoClassDefFoundError: com.arthenica.mobileffmpeg.Config at com.arthenica.mobileffmpeg.Config.ffmpegExecute(Config.java:623) at com.arthenica.mobileffmpeg.AsyncFFmpegExecuteTask.doInBackground(AsyncFFmpegExecuteTask.java:54) at com.arthenica.mobileffmpeg.AsyncFFmpegExecuteTask.doInBackground(AsyncFFmpegExecuteTask.java:29) at android.os.AsyncTask$2.call(AsyncTask.java:333) at java.util.concurrent.FutureTask.run(FutureTask.java:266) 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)  Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libavfilter.so" not found at java.lang.Runtime.loadLibrary0(Runtime.java:1016) at java.lang.System.loadLibrary(System.java:1669) at com.arthenica.mobileffmpeg.Config.(Config.java:133) at com.arthenica.mobileffmpeg.Config.ffmpegExecute(Config.java:623)  at com.arthenica.mobileffmpeg.AsyncFFmpegExecuteTask.doInBackground(AsyncFFmpegExecuteTask.java:54)  at com.arthenica.mobileffmpeg.AsyncFFmpegExecuteTask.doInBackground(AsyncFFmpegExecuteTask.java:29)  at android.os.AsyncTask$2.call(AsyncTask.java:333)  at java.util.concurrent.FutureTask.run(FutureTask.java:266)  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) 

Environment

Other Add any other context about the problem here.

tanersener commented 3 years ago

Line numbers in your stack trace don't match Config.java file included in v4.4.LTS. Are you sure this is v4.4.LTS published on jcenter()?

When mobile-ffmpeg is loaded on application startup, it prints the version information and some info log lines to logcat. Can you share those logs please?

Additionally, your issue doesn't include API level information of your device and the command(s) you're trying to execute. Would you mind sharing them?

tanersener commented 3 years ago

@serkanucar See #132

serkanucar commented 3 years ago

I'm debugging on my Android 11 OPPO device. When I run the code below, I get the error message in the upper comment.

I'm using this version -> implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.4.LTS'

MediaInformation info = FFprobe.getMediaInformation(inVideoPath); Config.setLogLevel(Level.AV_LOG_ERROR); Config.enableStatisticsCallback(statistics -> { if (statistics == null) { return; } int timeInMilliseconds = statistics.getTime(); if (timeInMilliseconds > 0) { int totalVideoDuration = (int) Math.ceil(Double.parseDouble(info.getDuration())); String completePercentage = new BigDecimal(timeInMilliseconds / 1000).multiply(new BigDecimal(100)).divide(new BigDecimal(totalVideoDuration), 0, BigDecimal.ROUND_HALF_UP).toString(); } });

String[] commands = new String[]{"-y", "-i", inVideoPath, "-vcodec", "libx264", "-b:v", "2600k", "-acodec", "aac", "-movflags", "faststart", "-preset", "ultrafast", outVideoPath};

FFmpeg.executeAsync(commands, (executionId, rc) -> { if (rc == RETURN_CODE_SUCCESS) { File file = new File(outVideoPath); ... } else if (rc == RETURN_CODE_CANCEL) { FFmpeg.cancel(executionId); ... } else { FFmpeg.cancel(executionId); ... } });

GaoYi123 commented 3 years ago

Android 10 VIVO Occasionally encountered java.lang.UnsatisfiedLinkError: dlopen failed: library "libavfilter.so" not found at java.lang.Runtime.loadLibrary0(Runtime.java:1071) at java.lang.Runtime.loadLibrary0(Runtime.java:1007) at java.lang.System.loadLibrary(System.java:1667) at com.arthenica.mobileffmpeg.Config.(Config.java:147) at com.arthenica.mobileffmpeg.Config.enableLogCallback(Config.java:220) at com.ym.screenrecorder.ffmpeg.FFmpegExecuteUtils.initFFmpegLogCallBack(FFmpegExecuteUtils.java:88) at com.ym.screenrecorder.ffmpeg.FFmpegExecuteUtils.setFFmpegListener(FFmpegExecuteUtils.java:56) at com.ym.screenrecorder.ui.video.editor.VideoEditViewModel.lambda$runFFmpegCmd$0$VideoEditViewModel(VideoEditViewModel.java:335) at com.ym.screenrecorder.ui.video.editor.-$$Lambda$VideoEditViewModel$9xZlFskGbtGbk9d9CngnmNRau2U.run(Unknown Source:4) at java.lang.Thread.run(Thread.java:919)

Environment

Platform: [e.g. Android/] Architecture: [ arm64-v8a] Version (if applicable) [e.g. v1.2] Source branch (if applicable) [e.g. 'com.arthenica:mobile-ffmpeg-full-gpl:4.4'] Android Studio version [ 4.1.1]

Azharlnsel commented 3 years ago

I am facing the same issue but my case is different When i am running my app in a physical device via usb then the error given below occures, and if I kill my app then it shows no error It happens every time i try to run I have to kill the app after run and open the app again

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "libavfilter.so" not found at java.lang.Runtime.loadLibrary0(Runtime.java:1071) at java.lang.Runtime.loadLibrary0(Runtime.java:1007)

ghost commented 3 years ago

I have same issue with random times. On Galaxy S8. Android 9.

MobatiaArshad commented 3 years ago

I am facing this issues occasionally in all devices.

Which are:

- Unable to open zip file: /data/app/com.vlurb.tech-sKdR9gjoTZ0-bfviXVFgYQ==/base.apk

- java.lang.UnsatisfiedLinkError: dlopen failed: library "libavfilter.so" not found

2021-02-23 12:00:56.768 16233-16233/com.vlurb.tech E/System: Unable to open zip file: /data/app/com.vlurb.tech-sKdR9gjoTZ0-bfviXVFgYQ==/base.apk 2021-02-23 12:00:56.770 16233-16233/com.vlurb.tech E/System: java.io.FileNotFoundException: /data/app/com.vlurb.tech-sKdR9gjoTZ0-bfviXVFgYQ==/base.apk (No such file or directory) at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.(ZipFile.java:265) at java.util.zip.ZipFile.(ZipFile.java:187) at java.util.jar.JarFile.(JarFile.java:169) at java.util.jar.JarFile.(JarFile.java:106) at libcore.io.ClassPathURLStreamHandler.(ClassPathURLStreamHandler.java:46) at dalvik.system.DexPathList$NativeLibraryElement.maybeInit(DexPathList.java:864) at dalvik.system.DexPathList$NativeLibraryElement.findNativeLibrary(DexPathList.java:885) at dalvik.system.DexPathList.findLibrary(DexPathList.java:600) at dalvik.system.BaseDexClassLoader.findLibrary(BaseDexClassLoader.java:270) at java.lang.Runtime.loadLibrary0(Runtime.java:1060) at java.lang.Runtime.loadLibrary0(Runtime.java:1007) at java.lang.System.loadLibrary(System.java:1667) at com.arthenica.mobileffmpeg.AbiDetect.(AbiDetect.java:33) at com.arthenica.mobileffmpeg.AbiDetect.getNativeAbi(Native Method) at com.arthenica.mobileffmpeg.Config.(Config.java:131) at com.arthenica.mobileffmpeg.Config.ffmpegExecute(Config.java:637) at com.arthenica.mobileffmpeg.FFmpeg.execute(FFmpeg.java:68) at com.vlurb.tech.FFMPEG.FFMpegMediaConverter.FinalVolumeChange(FFMpegMediaConverter.java:184) at com.vlurb.tech.Activities.Recording.RecordActivity.ConvertToAAC(RecordActivity.java:596) at com.vlurb.tech.Activities.Recording.RecordActivity.StopRecording(RecordActivity.java:483) at com.vlurb.tech.Activities.Recording.RecordActivity.onClick(RecordActivity.java:321) at android.view.View.performClick(View.java:7161) at android.view.View.performClickInternal(View.java:7133) at android.view.View.access$3500(View.java:804) at android.view.View$PerformClick.run(View.java:27416) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:241) at android.app.ActivityThread.main(ActivityThread.java:7604) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) 2021-02-23 12:00:56.781 16233-16233/com.vlurb.tech E/AndroidRuntime: FATAL EXCEPTION: main Process: com.vlurb.tech, PID: 16233 java.lang.UnsatisfiedLinkError: dlopen failed: library "libavfilter.so" not found at java.lang.Runtime.loadLibrary0(Runtime.java:1071) at java.lang.Runtime.loadLibrary0(Runtime.java:1007) at java.lang.System.loadLibrary(System.java:1667) at com.arthenica.mobileffmpeg.Config.(Config.java:147) at com.arthenica.mobileffmpeg.Config.ffmpegExecute(Config.java:637) at com.arthenica.mobileffmpeg.FFmpeg.execute(FFmpeg.java:68) at com.vlurb.tech.FFMPEG.FFMpegMediaConverter.FinalVolumeChange(FFMpegMediaConverter.java:184) at com.vlurb.tech.Activities.Recording.RecordActivity.ConvertToAAC(RecordActivity.java:596) at com.vlurb.tech.Activities.Recording.RecordActivity.StopRecording(RecordActivity.java:483) at com.vlurb.tech.Activities.Recording.RecordActivity.onClick(RecordActivity.java:321) at android.view.View.performClick(View.java:7161) at android.view.View.performClickInternal(View.java:7133) at android.view.View.access$3500(View.java:804) at android.view.View$PerformClick.run(View.java:27416) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:241) at android.app.ActivityThread.main(ActivityThread.java:7604) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)

Azharlnsel commented 3 years ago

I have added

-keep class com.arthenica.mobileffmpeg.Config {
    native <methods>;
    void log(long, int, byte[]);
    void statistics(long, int, float, float, long , int, double, double);
}

-keep class com.arthenica.mobileffmpeg.AbiDetect {
    native <methods>;
}

in my proguard-rules.pro file and issue was fixed

MobatiaArshad commented 3 years ago

I have added

-keep class com.arthenica.mobileffmpeg.Config {
    native <methods>;
    void log(long, int, byte[]);
    void statistics(long, int, float, float, long , int, double, double);
}

-keep class com.arthenica.mobileffmpeg.AbiDetect {
    native <methods>;
}

in my proguard-rules.pro file and issue was fixed

Sorry to tell.. I thought this issue was fixed... but it hasn't.. is there any other solution?

tanersener commented 3 years ago

This issue is marked with missing-issue-template. I need to get more details to make a comment about it. See my previous posts please.

There are similar issues about java.lang.UnsatisfiedLinkError that were fixed before. One of them is #616. I don't know whether this is the same issue or not. I suggest applying the solution given there.

MobatiaArshad commented 3 years ago

This issue is marked with missing-issue-template. I need to get more details to make a comment about it. See my previous posts please.

There are similar issues about java.lang.UnsatisfiedLinkError that were fixed before. One of them is #616. I don't know whether this is the same issue or not. I suggest applying the solution given there.

I have gone through the issue #616. I was using mavenCentral() below the jcenter(), so I made the following changes in the build.gradle in my project.

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

showing Loaded mobile-ffmpeg-full-arm-v7a-neon-4.4-lts-20200803 on the logcat when ffmpeg is executed

hope this will solve the issue