I am trying to use JavaCV to create video from set of images in my application. I use this code for getting it:
private ArrayList<String> mSelectedImages;
ArrayList<opencv_core.IplImage> images = new ArrayList<>();
for (String path : mSelectedImages) {
opencv_core.IplImage img = cvLoadImage(path);
images.add(img);
}
FFmpegFrameRecorder frameRecorder = new FFmpegFrameRecorder(outputFilePath, 640, 640, 0);
try {
frameRecorder.setVideoCodec(13);
frameRecorder.setFrameRate(30);
frameRecorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P); frameRecorder.start();
for (int i = 0; i < numOfSlides; i++) {
for (int j = 0; j < numOfFramesPerSlide; j++) {
frameRecorder.record(images.get(i));
}
}
frameRecorder.stop();
} catch (Exception e) {
e.printStackTrace();
}
Unfortunately I can't get desired video, instead of it I'm getting error:
java.lang.NoClassDefFoundError: java.lang.ClassNotFoundException: org.bytedeco.javacpp.opencv_core
at org.bytedeco.javacpp.Loader.load(Loader.java:387)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.opencv_highgui.<clinit>(opencv_highgui.java:13)
at oleg.osipenko.agoo.utilities.CodeVideoService.onHandleIntent(CodeVideoService.java:71)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.os.HandlerThread.run(HandlerThread.java:60)
Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacpp.opencv_core
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:217)
at org.bytedeco.javacpp.Loader.load(Loader.java:385)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.opencv_highgui.<clinit>(opencv_highgui.java:13)
at oleg.osipenko.agoo.utilities.CodeVideoService.onHandleIntent(CodeVideoService.java:71)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.os.HandlerThread.run(HandlerThread.java:60)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load jniopencv_core from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/oleg.osipenko.agoo-1.apk"],nativeLibraryDirectories=[/data/app-lib/oleg.osipenko.agoo-1, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:514)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
at org.bytedeco.javacpp.Loader.load(Loader.java:410)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.opencv_core.<clinit>(opencv_core.java:10)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:217)
at org.bytedeco.javacpp.Loader.load(Loader.java:385)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.opencv_highgui.<clinit>(opencv_highgui.java:13)
at oleg.osipenko.agoo.utilities.CodeVideoService.onHandleIntent(CodeVideoService.java:71)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.os.HandlerThread.run(HandlerThread.java:60)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load opencv_core from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/oleg.osipenko.agoo-1.apk"],nativeLibraryDirectories=[/data/app-lib/oleg.osipenko.agoo-1, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:514)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
at org.bytedeco.javacpp.Loader.load(Loader.java:401)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.opencv_core.<clinit>(opencv_core.java:10)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:217)
at org.bytedeco.javacpp.Loader.load(Loader.java:385)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.opencv_highgui.<clinit>(opencv_highgui.java:13)
at oleg.osipenko.agoo.utilities.CodeVideoService.onHandleIntent(CodeVideoService.java:71)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.os.HandlerThread.run(HandlerThread.java:60)
I followed instructions on your github page and did all the tricks I've managed to find, but result stays the same.
This is the part of my build script:
dependencies {
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.android.support:support-v4:20.+'
compile 'com.squareup.picasso:picasso:2.3.2'
compile project(':Aviary-SDK')
compile project(':dynamicgrid')
compile files('libs/ffmpeg.jar')
compile files('libs/javacpp.jar')
compile files('libs/javacv.jar')
compile files('libs/opencv.jar')
compile files('libs/armeabi.jar')
compile files('libs/ffmpeg-android-arm.jar')
compile files('libs/opencv-android-arm.jar')
}
armebi.jar - is a jar archive I made from *.so files I extracted from ffmpeg-android-arm.jar and opencv-android-arm.jar. I also tried to extract it to libs/armeabi directory and include it to my build script using command
compile fileTree('libs/armeabi')
But I still have the same error. Any ideas on how can I get working project?