问题
I downloaded JavaCV-1-3-1.
Now I have 2 questions:
How can I import JavaCV to Android Studio for using?
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