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

Using in android #76

Open
Hosseinyzr opened this issue Jun 5, 2020 · 4 comments
Open

Using in android #76

Hosseinyzr opened this issue Jun 5, 2020 · 4 comments

Comments

@Hosseinyzr
Copy link

Hi, thank you for your lib.
can we use this lib in android?
for example using .so files instead of ffmpeg binary...

@kokorin
Copy link
Owner

kokorin commented Jun 5, 2020

Hi @Hosseinyzr ,

Honestly I've never checked it on android. But I'm also interested in this check and fixes (if they are required). Probably it works, since android is based on linux, but I'm not 100% sure.

Denis.

@Hosseinyzr
Copy link
Author

I tried to to this.
I downloaded on binary from here:
https://github.com/Khang-NT/ffmpeg-binary-android/releases

and then:

 Path BIN = Paths.get(Environment.getExternalStorageDirectory().getPath());
        Path VIDEO_MP4 = Paths.get(new File(Environment.getExternalStorageDirectory().getPath(),"2.mp4").getPath());
        Path OUTPUT_MP4 =Paths.get(new File(Environment.getExternalStorageDirectory().getPath(),"out.mp4").getPath());

        ProgressListener listener = new ProgressListener() {
            @Override
            public void onProgress(FFmpegProgress progress) {
                //TODO handle progress data
            }
        };


        FFmpegResult result = FFmpeg.atPath(BIN)
                .addInput(UrlInput.fromPath(VIDEO_MP4))
                .addOutput(UrlOutput.toPath(OUTPUT_MP4)
                        .copyAllCodecs()
                )
                // This is optional
                .setProgressListener(listener)
                .execute();

    }

but this is error:

Caused by: java.lang.RuntimeException: Failed to start process.
      at com.github.kokorin.jaffree.process.ProcessHandler.execute(ProcessHandler.java:87)
      at com.github.kokorin.jaffree.ffmpeg.FFmpeg.execute(FFmpeg.java:161)
      at com.example.ffmpegtest.MainActivity.onCreate(MainActivity.java:46)
      at android.app.Activity.performCreate(Activity.java:7327)
      at android.app.Activity.performCreate(Activity.java:7318)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3093)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3256) 
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1947) 
      at android.os.Handler.dispatchMessage(Handler.java:106) 
      at android.os.Looper.loop(Looper.java:214) 
      at android.app.ActivityThread.main(ActivityThread.java:7037) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965) 
   Caused by: java.io.IOException: Cannot run program "/storage/emulated/0/ffmpeg": error=13, Permission denied
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050)
      at com.github.kokorin.jaffree.process.ProcessHandler.execute(ProcessHandler.java:83)
      at com.github.kokorin.jaffree.ffmpeg.FFmpeg.execute(FFmpeg.java:161) 
      at com.example.ffmpegtest.MainActivity.onCreate(MainActivity.java:46) 
      at android.app.Activity.performCreate(Activity.java:7327) 
      at android.app.Activity.performCreate(Activity.java:7318) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3093) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3256) 
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1947) 
      at android.os.Handler.dispatchMessage(Handler.java:106) 
      at android.os.Looper.loop(Looper.java:214) 
      at android.app.ActivityThread.main(ActivityThread.java:7037) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965) 
   Caused by: java.io.IOException: error=13, Permission denied

note that I give the app read /write permision

@kokorin
Copy link
Owner

kokorin commented Jun 5, 2020 via email

@Hosseinyzr
Copy link
Author

Yes, Actually it is about executable file...
some thing about unix permission.
It would be a very much favor if you take some time to check how can we use this lib an android...
maybe with shared libraries , .so files...

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