user3404171
user3404171

Reputation: 113

JavaCV in Android

I downloaded JavaCV-1-3-1.

Now I have 2 questions:

  1. How can I import JavaCV to Android Studio for using?

  2. Can be used from FFMPEG commands with JavaCV?

Upvotes: 0

Views: 4770

Answers (2)

Aditya Vyas-Lakhan
Aditya Vyas-Lakhan

Reputation: 13555

To import java cv add this to gradle

 dependencies {
       compile 'org.bytedeco:javacv:+'
compile 'org.bytedeco.javacpp-presets:opencv:3.0.0-1.1:android-x86'
compile 'org.bytedeco.javacpp-presets:ffmpeg:2.8.1-1.1:android-x86'
compile 'org.bytedeco.javacpp-presets:opencv:3.0.0-1.1:android-arm'
compile 'org.bytedeco.javacpp-presets:ffmpeg:2.8.1-1.1:android-arm' 
    }

Upvotes: 3

Kishore Jethava
Kishore Jethava

Reputation: 6834

You can also use WritingMinds library. it's easy to implement.

Dependency

compile 'com.writingminds:FFmpegAndroid:0.3.2'

You can do video related processing using execute()

sample code

final FFmpeg ffmpeg = FFmpeg.getInstance(activity);
        try {
            ffmpeg.loadBinary(new LoadBinaryResponseHandler() {

                @Override
                public void onStart() {}
                @Override
                public void onFailure() {}
                @Override
                public void onSuccess() {

                        String cropParams = "720:754:0:172";

                        String[] cmd = {"-i"
                                , originalPath
                                , "-vf"
                                ,cropParams
                                ,"-threads"
                                ,"5"
                                ,"-preset"
                                ,"ultrafast"
                                ,croppedPath};
                        // Execute cropping of video
                        ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
                            @Override
                            public void onStart() {
                            }
                            @Override
                            public void onProgress(String message) {
                                Log.i("Square", "progress : " +message);
                            }
                            @Override
                            public void onFailure(String message) {
                                Log.i("Square", "total fail : " + message);
                            }
                            @Override
                            public void onSuccess(String message) {
                                Log.i("Square", "Cropped video created.");

                            }
                            @Override
                            public void onFinish() {

                            }
                        });
                    } catch (FFmpegCommandAlreadyRunningException e) {
                        // Handle if FFmpeg is already running
                    }
                }
            });
        } catch (FFmpegNotSupportedException e) {
            // Handle if FFmpeg is not supported by device
        }

Upvotes: 2

Related Questions