JavaCV in Android

限于喜欢 提交于 2019-12-08 11:37:47

问题


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?


回答1:


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' 
    }



回答2:


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
        }


来源:https://stackoverflow.com/questions/42342834/javacv-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!