Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load FFmpeg lib #47

Open
Jomy10 opened this issue Jun 15, 2021 · 2 comments
Open

Failed to load FFmpeg lib #47

Jomy10 opened this issue Jun 15, 2021 · 2 comments

Comments

@Jomy10
Copy link

Jomy10 commented Jun 15, 2021

Hi. I stumbled across this library and it looks very promising.

I added this to my application:

public class App extends application {
    @Override
    public void onCreate() {
        AndroidAudioConverter.load(this, new ILoadCallback() {
            @Override
            public void onSuccess() {
                android.util.Log.d(TAG, "FFmpeg is supported by the device. Succesfully loaded AndroidAudioConverter library.");
            }
            @Override
            public void onFailure(Exception error) {
                // FFmpeg is not supported by device
                Log.w(TAG, "FFmpeg is not supported by this device.", error);
            }
        });
    }
}

And got the following error:

W/Application: FFmpeg is not supported by this device.
    java.lang.Exception: Failed to loaded FFmpeg lib
        at cafe.adriel.androidaudioconverter.AndroidAudioConverter$1.onFailure(AndroidAudioConverter.java:50)
        at com.github.hiteshsondhi88.libffmpeg.FFmpegLoadLibraryAsyncTask.onPostExecute(FFmpegLoadLibraryAsyncTask.java:54)
        at com.github.hiteshsondhi88.libffmpeg.FFmpegLoadLibraryAsyncTask.onPostExecute(FFmpegLoadLibraryAsyncTask.java:8)
        at android.os.AsyncTask.finish(AsyncTask.java:771)
        at android.os.AsyncTask.access$900(AsyncTask.java:199)
        at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

I then looked into the source code of your project and found that the load method does this:

try {
            FFmpeg.getInstance(context).loadBinary(new FFmpegLoadBinaryResponseHandler() {
                        @Override
                        public void onStart() {

                        }

                        @Override
                        public void onSuccess() {
                            loaded = true;
                            callback.onSuccess();
                        }

                        @Override
                        public void onFailure() {
                            loaded = false;
                            callback.onFailure(new Exception("Failed to loaded FFmpeg lib"));
                        }

                        @Override
                        public void onFinish() {

                        }
                    });
        } catch (Exception e){
            loaded = false;
            callback.onFailure(e);
        }
    }

So, I pasted that into my code and replaced catch (exception e) {...} with catch(exception e) {e.printStackTrace();.

I ran that and got the following error:

E/FFmpeg: issue in coping binary from assets to data. 
    java.io.FileNotFoundException: x86/ffmpeg
        at android.content.res.AssetManager.nativeOpenAsset(Native Method)
        at android.content.res.AssetManager.open(AssetManager.java:874)
        at android.content.res.AssetManager.open(AssetManager.java:851)
        at com.github.hiteshsondhi88.libffmpeg.FileUtils.copyBinaryFromAssetsToData(FileUtils.java:29)
        at com.github.hiteshsondhi88.libffmpeg.FFmpegLoadLibraryAsyncTask.doInBackground(FFmpegLoadLibraryAsyncTask.java:27)
        at com.github.hiteshsondhi88.libffmpeg.FFmpegLoadLibraryAsyncTask.doInBackground(FFmpegLoadLibraryAsyncTask.java:8)
        at android.os.AsyncTask$3.call(AsyncTask.java:394)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
        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:923)

So this means that FFmpeg is not installed I guess?

I looked into the source code of the ffmpeg-android-java and found where the FFmpeg file should be located.
I ran:

System.out.println(this.getFilesDir() + File.separator + "ffmpeg");

And got as output:

I/System.out: /data/user/0/be.ksa.voetje/files/ffmpeg

I then ran

System.out.println(new File(this.getFilesDir() + File.separator + "ffmpeg").exists());

And got false, so the file does indeed not exist.

I'm unfamiliar with the FFmpeg library, so I really have no idea on what I should do now.
If you could help me with this one, that would be wonderful.

Thank you in advance.
Jonas

@ltfhhanum
Copy link

we have the same issue, and I am also looking at how to fix it. did you fix it?

@Jomy10
Copy link
Author

Jomy10 commented Jun 30, 2021

we have the same issue, and I am also looking at how to fix it. did you fix it?

I used the code of this: https://github.com/tqnst/MP4ParserMergeAudioVideo/blob/master/Mp4ParserSample-master/src/jp/classmethod/sample/mp4parser/MainActivity.java#L335-L442

and made something on my own

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants