Guide to how could I compile JavaCV with FFMpeg with Webm (VP8) support

875 views
Skip to first unread message

Dan Damian

unread,
Sep 9, 2015, 9:44:21 AM9/9/15
to javacv
Hello, 

I'm developing an Android app using JavaCV.
I want to implement a Vine Style recording app.
So I'm recording frame by frame and encoding them using org.bytedeco.javacv.FFmpegFrameRecorder (javacv-0.11.jar).

I've added to my lib folder the follwing jars:
ffmpeg.jar
ffmpeg-android-arm.jar
javacpp-0.11.jar
javacv-0.11.jar
opencv.jar
opencv-android-arm.jar

Currently I can encode my movies only in h264 or mp4 formats but I need to encode them as webm (vp8).

I don't know how could I compile javacv with support for webm, for the Android platform.
Or maybe what I've said before it's incorrect, and I should ask: I don't know how could I compile ffmpeg with support for webm, for the Android platform.


Any help, much appreciated!

Dan
Screenshot from 2015-09-08 21:04:35.png

Samuel Audet

unread,
Sep 10, 2015, 10:01:54 AM9/10/15
to jav...@googlegroups.com
On 09/09/2015 03:11 AM, Dan Damian wrote:
> Hello,
>
> I'm developing an Android app using JavaCV.
> I want to implement a Vine Style recording app.
> So I'm recording frame by frame and encoding them using
> org.bytedeco.javacv.FFmpegFrameRecorder (javacv-0.11.jar).

Use version 1.0. It's been linked with libvpx already.

Samuel

Dan Damian

unread,
Sep 11, 2015, 5:35:26 AM9/11/15
to javacv
Thank you Samuel for taking the time!

What about libvorbis, is this linked also?

Samuel Audet

unread,
Sep 12, 2015, 3:05:03 AM9/12/15
to jav...@googlegroups.com
On 09/11/2015 06:35 PM, Dan Damian wrote:
> Thank you Samuel for taking the time!
>
> What about libvorbis, is this linked also?

No, as we can see from the list here it's not in there:
https://github.com/bytedeco/javacpp-presets/blob/master/ffmpeg/cppbuild.sh

If you could take some time to add it, your contribution would be very
much welcome! Thank you

Samuel

Dan Damian

unread,
Sep 12, 2015, 4:14:17 PM9/12/15
to javacv
I've downloaded Then looked in the ffmpeg-android-arm.jar and no trace of libvpx.so, this meaning ffmpeg is not compiled with support for VP8.
Also, in my code, when I chose avcodec.AV_CODEC_ID_VP8  as the video codec, my Android app throws the following error:

org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -22: Could not open video codec.
09-12 20:34:00.799    6276-6598/xyz.mydognewvr W/System.err﹕ at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:527)
09-12 20:34:00.799    6276-6598/xyz.mydognewvr W/System.err﹕ at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:288)


On the other hand, I've run javacpp-presets/cppbuild.sh
# bash cppbuild.sh -platform android-arm install ffmpeg 
without any success. The scripts were designed to work with android-ndk/toolchains/arm-linux-androideabi-4.6 bu tmy minimum is 
android-ndk-r10e/toolchains/arm-linux-androideabi-4.8....

I'll dig more tomorrow and I would appreciate if you would have any helping idea. :)

Thanks,

Dan

Samuel Audet

unread,
Sep 12, 2015, 9:03:15 PM9/12/15
to jav...@googlegroups.com
On 09/13/2015 05:14 AM, Dan Damian wrote:
> Then looked in the ffmpeg-android-arm.jar and no trace of libvpx.so, this meaning ffmpeg is not compiled with support for VP8.

It's linked with statically; it won't show up as a separate library.

> Also, in my code, when I chose avcodec.AV_CODEC_ID_VP8 as the video codec, my Android app throws the following error:
>
> org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -22: Could not open video codec.
> 09-12 20:34:00.799 6276-6598/xyz.mydognewvr W/System.err﹕ at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:527)
> 09-12 20:34:00.799 6276-6598/xyz.mydognewvr W/System.err﹕ at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:288)

Does this happen only on Android? Or does it happen on other platforms too?

> On the other hand, I've run javacpp-presets/cppbuild.sh
> # bash cppbuild.sh -platform android-arm install ffmpeg
> without any success. The scripts were designed to work with android-ndk/toolchains/arm-linux-androideabi-4.6 bu tmy minimum is
> android-ndk-r10e/toolchains/arm-linux-androideabi-4.8....

Yes, that's since been updated in the source repository. Use git to get
the latest version of the source code from GitHub.

Samuel

Dan Damian

unread,
Sep 14, 2015, 4:45:12 PM9/14/15
to javacv


On Sunday, September 13, 2015 at 4:03:15 AM UTC+3, Samuel Audet wrote:
On 09/13/2015 05:14 AM, Dan Damian wrote:
> Then looked in the ffmpeg-android-arm.jar and no trace of libvpx.so, this meaning ffmpeg is not compiled with support for VP8.

>>It's linked with statically; it won't show up as a separate library.
Ok, I see. 
> Also, in my code, when I chose avcodec.AV_CODEC_ID_VP8  as the video codec, my Android app throws the following error:
>
> org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -22: Could not open video codec.
> 09-12 20:34:00.799    6276-6598/xyz.mydognewvr W/System.err﹕ at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:527)
> 09-12 20:34:00.799    6276-6598/xyz.mydognewvr W/System.err﹕ at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:288)

>>Does this happen only on Android? Or does it happen on other platforms too?
Unfortunately I'm unable to test on other platforms, except Android.
 
> On the other hand, I've run javacpp-presets/cppbuild.sh
> # bash cppbuild.sh -platform android-arm install ffmpeg
> without any success. The scripts were designed to work with android-ndk/toolchains/arm-linux-androideabi-4.6 bu tmy minimum is
> android-ndk-r10e/toolchains/arm-linux-androideabi-4.8....

>>Yes, that's since been updated in the source repository. Use git to get
>>the latest version of the source code from GitHub.
I've git clone the last version of javacpp-presets which is 1.0.
I've noticed a problem in javacpp-presets/ffmpeg/cppbuild.sh:
at line 27, where it states that $FFMPEG_VERSION=2.8
bu then at line 88, patch -Np1 < ../../../ffmpeg-$FFMPEG_VERSION-android.patch, resolving to 
patch -Np1 < ../../../ffmpeg-2.8-android.patch sayis file not found as in the javacpp-presets/ffmpeg only ffmpeg-2.7.1-android.patch and ffmpeg-2.7.1-macosx.patch can be found. So the scripts stops at patch -Np1 < ../../../ffmpeg-$FFMPEG_VERSION-android.patch and doesnt execute, ./configure, make -j4 and make install for ffmpeg.

Anyway I've solved this problem, either by changing the FFMPEG_VERSION to 2.7.1 or by commenting the line 88 (that applies tha patch), so that the script could go on. But in both cases, cppbuild.sh didn't produce any ffmpeg.jar. Isn't this what is expected from this build? To create arm specific jars?

Thanks, 

Dan
 

Samuel Audet

unread,
Sep 14, 2015, 7:10:35 PM9/14/15
to jav...@googlegroups.com
On 09/15/2015 05:45 AM, Dan Damian wrote:
> I've git clone the last version of javacpp-presets which is 1.0.
> /git clone https://github.com/bytedeco/javacpp-presets.git/
> I've noticed a problem in javacpp-presets/ffmpeg/cppbuild.sh:
> at line 27, where it states that /$FFMPEG_VERSION=2.8/
> bu then at line 88, /patch -Np1 <
> ../../../ffmpeg-$FFMPEG_VERSION-android.patch/, resolving to
> /patch -Np1 < ../../../ffmpeg-2.8-android.patch/ sayis /file not found/
> as in the javacpp-presets/ffmpeg only ffmpeg-2.7.1-android.patch
> and ffmpeg-2.7.1-macosx.patch can be found. So the scripts stops
> at patch -Np1 < ../../../ffmpeg-$FFMPEG_VERSION-android.patch and doesnt
> execute, ./configure, make -j4 and make install for ffmpeg.

Oops, I forgot to rename the patch files. Just rename them before
running the script. Sorry about that.

> Anyway I've solved this problem, either by changing the FFMPEG_VERSION
> to 2.7.1 or by commenting the line 88 (that applies tha patch), so that
> the script could go on. But in both cases, cppbuild.sh didn't produce
> any ffmpeg.jar. Isn't this what is expected from this build? To create
> arm specific jars?

We need to run `mvn install` after to get that file. Please try to
follow the build instructions here:
https://github.com/bytedeco/javacpp-presets/#build-instructions
Thanks!

Samuel

Dan Damian

unread,
Sep 15, 2015, 4:35:56 PM9/15/15
to javacv


On Tuesday, September 15, 2015 at 2:10:35 AM UTC+3, Samuel Audet wrote:
On 09/15/2015 05:45 AM, Dan Damian wrote:
> I've git clone the last version of javacpp-presets which is 1.0.
> /git clone https://github.com/bytedeco/javacpp-presets.git/
> I've noticed a problem in javacpp-presets/ffmpeg/cppbuild.sh:
> at line 27, where it states that /$FFMPEG_VERSION=2.8/
> bu then at line 88, /patch -Np1 <
> ../../../ffmpeg-$FFMPEG_VERSION-android.patch/, resolving to
> /patch -Np1 < ../../../ffmpeg-2.8-android.patch/ sayis /file not found/
> as in the javacpp-presets/ffmpeg only ffmpeg-2.7.1-android.patch
> and ffmpeg-2.7.1-macosx.patch can be found. So the scripts stops
> at patch -Np1 < ../../../ffmpeg-$FFMPEG_VERSION-android.patch and doesnt
> execute, ./configure, make -j4 and make install for ffmpeg.

Oops, I forgot to rename the patch files. Just rename them before
running the script. Sorry about that.
I've cloned last version of javacpp-presets and I've noticed that the patch was renamed to ffmpeg-2.8-android.patch.
I run again #bash cppbuild.sh -platform android-arm install ffmpeg
but in the end at the line 88 from javacpp-presets/ffmpeg/cppbuild.sh stating patch -Np1 < ../../../ffmpeg-$FFMPEG_VERSION-android.patch, the following errors occur:
patching file configure
Hunk #1 succeeded at 5263 with fuzz 1 (offset 139 lines).
Hunk #2 FAILED at 5154.
1 out of 2 hunks FAILED -- saving rejects to file configure.rej
patching file library.mak
Hunk #1 FAILED at 52.
Hunk #2 succeeded at 74 (offset 1 line).
Hunk #3 succeeded at 94 (offset 1 line).
1 out of 3 hunks FAILED -- saving rejects to file library.mak.rej

and it stops from executing the following steps: of ./configure ... (the configuration command for ffmpeg), make -j4, make install.

Ok, I've commented out again line 88 from javacpp-presets/ffmpeg/cppbuild.sh so that the process could reach the end, but when it reaches to ./configure ffmpeg it throws the following errors

ERROR: speex not found using pkg-config

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user at ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solve the problem.

 
> Anyway I've solved this problem, either by changing the FFMPEG_VERSION
> to 2.7.1 or by commenting the line 88 (that applies tha patch), so that
> the script could go on. But in both cases, cppbuild.sh didn't produce
> any ffmpeg.jar. Isn't this what is expected from this build? To create
> arm specific jars?

We need to run `mvn install` after to get that file. Please try to
follow the build instructions here:
https://github.com/bytedeco/javacpp-presets/#build-instructions
Thanks!

Samuel

Couldn't reach this level....

Samuel Audet

unread,
Sep 15, 2015, 9:57:27 PM9/15/15
to jav...@googlegroups.com
On 09/16/2015 05:35 AM, Dan Damian wrote:
> I've cloned last version of javacpp-presets and I've noticed that the
> patch was renamed to ffmpeg-2.8-android.patch.
> I run again #bash cppbuild.sh -platform android-arm install ffmpeg
> but in the end at the line 88 from javacpp-presets/ffmpeg/cppbuild.sh
> stating *patch -Np1 < ../../../ffmpeg-$FFMPEG_VERSION-android.patch*,
> the following errors occur:
> /patching file configure/
> /Hunk #1 succeeded at 5263 with fuzz 1 (offset 139 lines)./
> /Hunk #2 FAILED at 5154./
> /1 out of 2 hunks FAILED -- saving rejects to file configure.rej/
> /patching file library.mak/
> /Hunk #1 FAILED at 52./
> /Hunk #2 succeeded at 74 (offset 1 line)./
> /Hunk #3 succeeded at 94 (offset 1 line)./
> /1 out of 3 hunks FAILED -- saving rejects to file library.mak.rej/

Strange, it works fine here with my version of "patch". I guess we
should update it :) For now though, just apply the patches manually. It
will work fine.

Samuel

arca...@gmail.com

unread,
Sep 17, 2015, 5:11:09 PM9/17/15
to jav...@googlegroups.com
Hello Samuel, 
I'm so I dont know how...desperate maybe, i'm trying for some (a lot of) time to compile javacv, ffmpeg and opencv with vp8 support without any success .... :(( 
1) Tonight I've cloned again javacpp-preset.
2) ~/javacpp-presets$ ./cppbuild.sh -platform android-arm install ffmpeg/
3) step 2 ended up with
...Creating makefiles for armv7-android-gcc libs
Creating makefiles for armv7-android-gcc docs
    [DEP] vpx_config.c.d
    [CC] vpx_config.c.o
    [CREATE] vpx.pc
    [AR] libvpx_g.a
    [STRIP] libvpx.a < libvpx_g.a
make[1]: Nothing to be done for `all'.
    [INSTALL] /home/dd/javacpp-presets/ffmpeg/cppbuild/android-arm/lib/libvpx.a
    [INSTALL] /home/dd/javacpp-presets/ffmpeg/cppbuild/android-arm/lib/pkgconfig/vpx.pc
make[1]: Nothing to be done for `install'.
patching file configure
Hunk #1 succeeded at 5263 with fuzz 1 (offset 139 lines).
Hunk #2 FAILED at 5154.
1 out of 2 hunks FAILED -- saving rejects to file configure.rej
patching file library.mak
Hunk #1 FAILED at 52.
Hunk #2 succeeded at 74 (offset 1 line).
Hunk #3 succeeded at 94 (offset 1 line).
1 out of 3 hunks FAILED -- saving rejects to file library.mak.rej

4) then went to and tried to apply the patch manually as you said...
~/javacpp-presets/ffmpeg/cppbuild/android-arm/ffmpeg-2.8$
and it faild with
~/javacpp-presets/ffmpeg/cppbuild/android-arm/ffmpeg-2.8$ patch -Np1 < ../../../ffmpeg-2.8-android.patch 
patching file configure
Reversed (or previously applied) patch detected!  Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file configure.rej
patching file library.mak
Hunk #1 FAILED at 52.
Hunk #2 FAILED at 73.
Hunk #3 FAILED at 94.
3 out of 3 hunks FAILED -- saving rejects to file library.mak.rej
5) then commented out the patch -Np1 < ... from ffmpeg/cppbuild.sh and run again 
~/javacpp-presets$ ./cppbuild.sh -platform android-arm install ffmpeg/
6) ended up with
Creating makefiles for armv7-android-gcc libs
Creating makefiles for armv7-android-gcc docs
    [DEP] vpx_config.c.d
    [CC] vpx_config.c.o
    [CREATE] vpx.pc
    [AR] libvpx_g.a
    [STRIP] libvpx.a < libvpx_g.a
make[1]: Nothing to be done for `all'.
    [INSTALL] /home/dd/javacpp-presets/ffmpeg/cppbuild/android-arm/lib/libvpx.a
    [INSTALL] /home/dd/javacpp-presets/ffmpeg/cppbuild/android-arm/lib/pkgconfig/vpx.pc
make[1]: Nothing to be done for `install'.
*** skipping patch ***
ERROR: speex not found using pkg-config

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpe...@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solve the problem.


I'm building on ubuntu 14.04 LTS 64 bit version.
Can you please create a new javacv-1.0-bin.zip (131 MB) with the jars with vp8 support. I'm stucked for some time with my project as I'm unable to encode in vp8 format...

Thanks, 

Dan




--

--- You received this message because you are subscribed to a topic in the Google Groups "javacv" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/javacv/-7mkmuiDMt4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to javacv+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Samuel Audet

unread,
Sep 20, 2015, 9:48:33 AM9/20/15
to jav...@googlegroups.com
On 09/18/2015 06:11 AM, arca...@gmail.com wrote:
> patching file configure
> Hunk #1 succeeded at 5263 with fuzz 1 (offset 139 lines).
> Hunk #2 FAILED at 5154.
> 1 out of 2 hunks FAILED -- saving rejects to file configure.rej
> patching file library.mak
> Hunk #1 FAILED at 52.
> Hunk #2 succeeded at 74 (offset 1 line).
> Hunk #3 succeeded at 94 (offset 1 line).
> 1 out of 3 hunks FAILED -- saving rejects to file library.mak.rej

Ok, ok, you're right: The patches don't work. I don't know why I said
they did. Anyway, I've fixed the in this commit:
https://github.com/bytedeco/javacpp-presets/commit/94d64562f41ada58c394312bed740339df1664fa
It should work much better now.

Samuel

Dan Damian

unread,
Sep 21, 2015, 3:36:25 PM9/21/15
to javacv
Ok, so now it works building javacpp-presets for ffmpeg and opencv.
I did the following steps without any problems:
1) git clone <javacpp-prestes git url>
2) cd javacpp-presets
3) bash cppbuild.sh -platform android-arm install ffmpeg
4) mvn install -Pandroid-arm -Dplatform.root=$ANDROID_NDK --projects ffmpeg
------ everything went ok --------------
5) bash cppbuild.sh -platform android-arm install opencv
6) mvn install -Pandroid-arm -Dplatform.root=$ANDROID_NDK --projects opencv

Then cloned javacpp and compiled it for android-arm platform also. Very Important: if I was using javacpp.jar form the javacpp-presets-bin.zip or javacv-bin.zip when my android app was loaded the following error was thrown "java.lang.UnsatisfiedLinkError: org.bytedeco.javacpp.avutil"
6) git clone <javacpp git url>
7) mvn install -Pandroid-arm -Dplatform.root=$ANDROID_NDK
------ everything went ok --------------
After copying the resulted javacpp.jar in my project's libs, the above error disappeared but new errors appeared...

ERROR 1) 
after invoking the following lines of code
mFFmpegRecorder = new FFmpegFrameRecorder(Constants.VIDEOS_FOLDER_PATH + File.separator + mVideoFile, Constants.VIDEO_WIDTH, Constants.VIDEO_HEIGHT, 1);

mFFmpegRecorder.setVideoCodec(Constants.VIDEO_CODEC);// where Constants.VIDEO_CODEC = avcodec.AV_CODEC_ID_VP8;
[...]
try {
mFFmpegRecorder.start();
} catch (FFmpegFrameRecorder.Exception e) {
e.printStackTrace();
}

I get:
org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -22: Could not open video codec.
Even though I've built ffmepg with the default configuration which includes libvpx support.

ERROR 2)
after invoking the following lines of code
yuvIplImage = IplImage.create(Constants.VIDEO_WIDTH, Constants.VIDEO_HEIGHT, opencv_core.IPL_DEPTH_8U, 2);
I get:
 Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN2cv22SparseMatConstIteratormmEv" referenced by "libjniopencv_core.so"...
            at java.lang.Runtime.loadLibrary(Runtime.java:371)
            at java.lang.System.loadLibrary(System.java:988)
            at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:550)
            at org.bytedeco.javacpp.Loader.load(Loader.java:415)
            at org.bytedeco.javacpp.Loader.load(Loader.java:358)
            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:309)
            at org.bytedeco.javacpp.Loader.load(Loader.java:390)
            at org.bytedeco.javacpp.Loader.load(Loader.java:358)
            at org.bytedeco.javacpp.helper.opencv_core$AbstractArray.<clinit>(opencv_core.java:109)
            at xyz.myapp.gui.community.vr.ThreadVideoRecording.<init>(ThreadVideoRecording.java:43)
            at xyz.myapp.gui.community.vr.MyAppVideoRecordActivity$2.doInBackground(MyAppVideoRecordActivity.java:630)
            at xyz.myapp.gui.community.vr.MyAppVideoRecordActivity$2.doInBackground(MyAppVideoRecordActivity.java:526)
            at android.os.AsyncTask$2.call(AsyncTask.java:292)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/myapp.xyz.myappvr-2/base.apk"],nativeLibraryDirectories=[/data/app/myapp.xyz.myappvr-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libgnustl_static.so"

So as a conclusion I might say that:
1) I have a good built of ffmpeg and opencv
2) I have a good build of javacpp
3) but they don't work as assumed...

How should I proceed next...?

Dan Damian

unread,
Sep 23, 2015, 4:16:51 PM9/23/15
to javacv
Found a post relating to my error here where it seems that the problem was fixed....quite a while ago - Dec 2014...

Anyway, I've also upgraded my proguard to the latest stable version - 5.2.1 and added the rules indicated here to my proguard-rules.pro but the errors are still present....

Samuel Audet

unread,
Sep 24, 2015, 8:34:06 AM9/24/15
to jav...@googlegroups.com
On 09/22/2015 04:36 AM, Dan Damian wrote:
I get:
org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -22: Could not open video codec.
Even though I've built ffmepg with the default configuration which includes libvpx support.
Yes, I've heard reports that x265 and libvpx don't appear to work very well on Android... I'm not sure why. I'm always hoping for somebody to investigate this. Please post an issue on GitHub. BTW, does it happen on some other platforms like Linux or Windows?


I get:
 Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN2cv22SparseMatConstIteratormmEv" referenced by "libjniopencv_core.so"...
That probably just means you have mismatched versions of libraries. Make sure your app is using the right files. You might have to uninstall everything completely and manually, and then reinstall.

Samuel

Samuel Audet

unread,
Sep 24, 2015, 10:01:13 AM9/24/15
to jav...@googlegroups.com
On 09/24/2015 09:33 PM, Samuel Audet wrote:
I get:
 Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN2cv22SparseMatConstIteratormmEv" referenced by "libjniopencv_core.so"...
That probably just means you have mismatched versions of libraries. Make sure your app is using the right files. You might have to uninstall everything completely and manually, and then reinstall.

Ah, no, this is small regression. I've just fixed that in this commit:
https://github.com/bytedeco/javacpp-presets/commit/d0cd60bbac5f1dc92b8d225f143dfd94113c911e

Samuel

Dan Damian

unread,
Sep 24, 2015, 4:20:24 PM9/24/15
to javacv
Rebuilt opencv from scratch
1) bash cppbuild.sh -platform android-arm install opencv
2) mvn install -Pandroid-arm -Dplatform.root=$ANDROID_NDK --projects opencv

but the error somehow maintains. 
Bellow is the console

09-24 23:16:02.782    2989-3886/myapp.xyz.myappvr E/art﹕ dlopen("/data/app/myapp.xyz.myappvr-1/lib/arm/libjniopencv_core.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "_ZNK2cv16MinProblemSolver8Function7getDimsEv" referenced by "libjniopencv_core.so"...
09-24 23:16:02.959    2989-3886/myapp.xyz.myappvr E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
    Process: myapp.xyz.myappvr, PID: 2989
    java.lang.RuntimeException: An error occured while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:304)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
            at java.util.concurrent.FutureTask.run(FutureTask.java:242)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZNK2cv16MinProblemSolver8Function7getDimsEv" referenced by "libjniopencv_core.so"...
            at java.lang.Runtime.loadLibrary(Runtime.java:371)
            at java.lang.System.loadLibrary(System.java:988)
            at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:550)
            at org.bytedeco.javacpp.Loader.load(Loader.java:415)
            at org.bytedeco.javacpp.Loader.load(Loader.java:358)
            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:309)
            at org.bytedeco.javacpp.Loader.load(Loader.java:390)
            at org.bytedeco.javacpp.Loader.load(Loader.java:358)
            at org.bytedeco.javacpp.helper.opencv_core$AbstractArray.<clinit>(opencv_core.java:109)
            at xyz.myapp.gui.community.vr.ThreadVideoRecording.<init>(ThreadVideoRecording.java:43)
            at xyz.myapp.gui.community.vr.myappVideoRecordActivity$2.doInBackground(myappVideoRecordActivity.java:639)
            at xyz.myapp.gui.community.vr.myappVideoRecordActivity$2.doInBackground(myappVideoRecordActivity.java:535)
            at android.os.AsyncTask$2.call(AsyncTask.java:292)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/myapp.xyz.myappvr-1/base.apk"],nativeLibraryDirectories=[/data/app/myapp.xyz.myappvr-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libgnustl_static.so"
            at java.lang.Runtime.loadLibrary(Runtime.java:366)
            at java.lang.System.loadLibrary(System.java:988)
            at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:550)
            at org.bytedeco.javacpp.Loader.load(Loader.java:406)
            at org.bytedeco.javacpp.Loader.load(Loader.java:358)
            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:309)
            at org.bytedeco.javacpp.Loader.load(Loader.java:390)
            at org.bytedeco.javacpp.Loader.load(Loader.java:358)
            at org.bytedeco.javacpp.helper.opencv_core$AbstractArray.<clinit>(opencv_core.java:109)
            at xyz.myapp.gui.community.vr.ThreadVideoRecording.<init>(ThreadVideoRecording.java:43)
            at xyz.myapp.gui.community.vr.myappVideoRecordActivity$2.doInBackground(myappVideoRecordActivity.java:639)
            at xyz.myapp.gui.community.vr.myappVideoRecordActivity$2.doInBackground(myappVideoRecordActivity.java:535)

Dan Damian

unread,
Sep 24, 2015, 4:22:10 PM9/24/15
to javacv


On Thursday, September 24, 2015 at 3:34:06 PM UTC+3, Samuel Audet wrote:
On 09/22/2015 04:36 AM, Dan Damian wrote:
I get:
org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -22: Could not open video codec.
Even though I've built ffmepg with the default configuration which includes libvpx support.
Yes, I've heard reports that x265 and libvpx don't appear to work very well on Android... I'm not sure why. I'm always hoping for somebody to investigate this. Please post an issue on GitHub. BTW, does it happen on some other platforms like Linux or Windows?

Anyway, in the mean time, if you have any ideas about how could I start digging I'll be glad to receive advices.

Dan Damian

unread,
Sep 24, 2015, 4:23:25 PM9/24/15
to javacv
I'll try tomorrow on Linux and Windows also and I'll come back with feedback.

Samuel Audet

unread,
Sep 25, 2015, 3:53:51 AM9/25/15
to jav...@googlegroups.com
On 09/25/2015 05:20 AM, Dan Damian wrote:
> Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZNK2cv16MinProblemSolver8Function7getDimsEv" referenced by "libjniopencv_core.so"...

Looks like there were still a couple of those left. Should be all fixed
the latest commits:
https://github.com/bytedeco/javacpp/commit/5070834a7ebec8453c3d50384652ac33b59fcd99
https://github.com/bytedeco/javacpp-presets/commit/18c97c289acb18556103de2403d8524702c34af4

Thanks for reporting!

Samuel

arca...@gmail.com

unread,
Sep 26, 2015, 9:23:10 AM9/26/15
to jav...@googlegroups.com
Yep, it worked! Thanks! :)

No, I'll try to get rid of the "org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -22: Could not open video codec."

Maybe there are some resources trying to access symultaneously the codec...

Samuel Audet

unread,
Sep 26, 2015, 11:20:37 PM9/26/15
to jav...@googlegroups.com
On 09/26/2015 10:23 PM, arca...@gmail.com wrote:
> Yep, it worked! Thanks! :)
>
> No, I'll try to get rid of the "org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -22: Could not open video codec."
>
> Maybe there are some resources trying to access symultaneously the codec...

Great, thanks! Like I said, let's check if the same code works on other
platforms like Linux or Windows: That should give us clues about what is
wrong. Also, if it doesn't work on Linux or Windows either, then it's
easier to debug on those platforms, so no need to try to debug on Android.

Samuel

Dan Damian

unread,
Oct 1, 2015, 5:25:11 PM10/1/15
to javacv
Ok, so I've made some tests.
My results are:
 1) on Linux (Ubuntu 14.04 64 bits), I couldn't reproduce the error (instead obtained another error)
 2) on Windows 8, I couldn't reproduce the error

Steps to reproduce the error on Linux:
Checked and the error reproduces on Linux also (Ubuntu 14.04)

Steps to reproduce on Linux:
1) git clone <javacpp-prestes git url>
2) cd javacpp-presets
3) bash cppbuild.sh -platform linux-x86_64 install ffmpeg
4) mvn install -Plinux-x86_64 --projects ffmpeg
5) bash cppbuild.sh -platform linux-x86_64 install opencv
6) mvn install -Plinux-x86_64--projects opencv
7) git clone javacpp
8) mvn install javacpp
9) git clone javacv
10) unable to mvn install so instead tooked the jar from javacv-bin.zip
11) create a new project in Eclipse
12) run the class bellow:
package test.ffmpeg;

import org.bytedeco.javacpp.avcodec;
import org.bytedeco.javacv.FFmpegFrameRecorder;

public class TestFFMpeg {
public static void main(String[] args) {
FFmpegFrameRecorder mFFmpegRecorder = new FFmpegFrameRecorder("video.webm", 480, 480, 1);

mFFmpegRecorder.setVideoCodec(avcodec.AV_CODEC_ID_VP8);
try {
    mFFmpegRecorder.start();
} catch (FFmpegFrameRecorder.Exception e) {
    e.printStackTrace();
}
}

}

13) thrown the error bellow:
Output #0, webm, to 'video.webm':
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 480x480, q=-1--1, 400 kb/s, 30 tbn, 30 tbc
    Stream #0:1: Audio: vorbis, 44100 Hz, mono, fltp, 64 kb/s
[libvpx @ 0x7f68fc28d7e0] v1.4.0
[vorbis @ 0x7f68fc28e340] Current FFmpeg Vorbis encoder only supports 2 channels.
org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -1: Could not open audio codec.
at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:581)
at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:288)
at test.ffmpeg.TestFFMpeg.main(TestFFMpeg.java:14)


  Steps to reproduce the problem on Windows
1) tried to build ffmpeg and opencv but gave up after some errors
2) so instead downloaded javacv-1.0-bin.zip and tooked from there need jars (javacv.jar, javacpp.jar, ffmpeg.jar, ffmpeg-windows-x86_64, opencv.jar and opencv-windows-x86_64)
3) run the same class
package test.ffmpeg;

import org.bytedeco.javacpp.avcodec;
import org.bytedeco.javacv.FFmpegFrameRecorder;

public class TestFFMpeg {
public static void main(String[] args) {
FFmpegFrameRecorder mFFmpegRecorder = new FFmpegFrameRecorder("video.webm", 480, 480, 1);

mFFmpegRecorder.setVideoCodec(avcodec.AV_CODEC_ID_VP8);
try {
    mFFmpegRecorder.start();
} catch (FFmpegFrameRecorder.Exception e) {
    e.printStackTrace();
}
}

}

and obtained the output bellow.
Output #0, webm, to 'video.webm':
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 480x480, q=-1--1, 400 kb/s, 30 tbn, 30 tbc
    Stream #0:1: Audio: vorbis (libvorbis), 44100 Hz, mono, fltp, 64 kb/s
[libvpx @ 000000001779c940] v1.4.0

Samuel Audet

unread,
Oct 4, 2015, 1:41:10 AM10/4/15
to jav...@googlegroups.com
On 10/02/2015 06:25 AM, Dan Damian wrote:
Ok, so I've made some tests.
My results are:
 1) on Linux (Ubuntu 14.04 64 bits), I couldn't reproduce the error (instead obtained another error)

Great, thanks for testing this out!

So, it looks like the internal non-libvorbis FFmpeg Vorbis codec requires 2 channels, so just specifying 2 audio channels should fix that problem. Maybe you're encountering the same issue on Android. Could you try to specify 2 audio channels on both Linux and Android and see if that makes everything work or not? Thanks!

Samuel

arca...@gmail.com

unread,
Oct 4, 2015, 3:01:02 PM10/4/15
to jav...@googlegroups.com
1. Android
Configured 2 channels for FFMpegFrameRecorder, but on Android the error remains the same.
25367-25453/mydog.xyz.mydogvr W/linker﹕ libavformat.so: unused DT entry: type 0x6ffffffe arg 0x64b8
10-04 21:48:15.112  25367-25453/mydog.xyz.mydogvr W/linker﹕ libavformat.so: unused DT entry: type 0x6fffffff arg 0x2
10-04 21:48:15.122  25367-25453/mydog.xyz.mydogvr W/linker﹕ libjniavformat.so: unused DT entry: type 0x1d arg 0x165b2
10-04 21:48:15.122  25367-25453/mydog.xyz.mydogvr W/linker﹕ libjniavformat.so: unused DT entry: type 0x6ffffffe arg 0x1e52c
10-04 21:48:15.122  25367-25453/mydog.xyz.mydogvr W/linker﹕ libjniavformat.so: unused DT entry: type 0x6fffffff arg 0x1
10-04 21:48:15.193  25367-25453/mydog.xyz.mydogvr W/linker﹕ libswscale.so: unused DT entry: type 0x6ffffffe arg 0xdd0
10-04 21:48:15.193  25367-25453/mydog.xyz.mydogvr W/linker﹕ libswscale.so: unused DT entry: type 0x6fffffff arg 0x1
10-04 21:48:15.213  25367-25453/mydog.xyz.mydogvr W/linker﹕ libjniswscale.so: unused DT entry: type 0x1d arg 0x38f9
10-04 21:48:15.213  25367-25453/mydog.xyz.mydogvr W/linker﹕ libjniswscale.so: unused DT entry: type 0x6ffffffe arg 0x5a8c
10-04 21:48:15.213  25367-25453/mydog.xyz.mydogvr W/linker﹕ libjniswscale.so: unused DT entry: type 0x6fffffff arg 0x1
10-04 21:48:15.459  25367-25453/mydog.xyz.mydogvr W/System.err﹕ org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -22: Could not open video codec.
10-04 21:48:15.459  25367-25453/mydog.xyz.mydogvr W/System.err﹕ at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:527)
10-04 21:48:15.459  25367-25453/mydog.xyz.mydogvr W/System.err﹕ at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:288)

Clicking on the stacktrace, I can see that the FFMpegFrameRecorder is throwing the error at line 511:
if((ret = avcodec.avcodec_open2(this.video_c, this.video_codec, var12)) < 0) {
this.release();
throw new Exception("avcodec_open2() error " + ret + ": Could not open video codec.");
}
2. Linux
Configuring 2 channels solved the problem...odd.

So the code bellow,

package test.ffmpeg;

import org.bytedeco.javacpp.avcodec;
import org.bytedeco.javacv.FFmpegFrameRecorder;

public class TestFFMpeg {
public static void main(String[] args) {
FFmpegFrameRecorder mFFmpegRecorder = new FFmpegFrameRecorder("video.webm", 480, 480, 1);
               mFFmpegRecorder.setVideoCodec(avcodec.AV_CODEC_ID_VP8);
                mFFmpegRecorder.setAudioChannels(2);
try {
   mFFmpegRecorder.start();
} catch (FFmpegFrameRecorder.Exception e) {
   e.printStackTrace();
   return;
}
System.out.println("Everything wen fine. Start recording.");
}
}

Produced the output bellow:

Output #0, webm, to 'video.webm':
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 480x480, q=-1--1, 400 kb/s, 30 tbn, 30 tbc
    Stream #0:1: Audio: vorbis, 44100 Hz, stereo, fltp, 64 kb/s
[libvpx @ 0x7fde10285a20] v1.4.0
Everything wen fine. Start recording.

Thanks,

Dan

--

Samuel Audet

unread,
Oct 10, 2015, 10:13:00 AM10/10/15
to jav...@googlegroups.com
On 10/05/2015 04:00 AM, arca...@gmail.com wrote:
1. Android
Configured 2 channels for FFMpegFrameRecorder, but on Android the error remains the same.
25367-25453/mydog.xyz.mydogvr W/linker﹕ libavformat.so: unused DT entry: type 0x6ffffffe arg 0x64b8
10-04 21:48:15.112  25367-25453/mydog.xyz.mydogvr W/linker﹕ libavformat.so: unused DT entry: type 0x6fffffff arg 0x2
10-04 21:48:15.122  25367-25453/mydog.xyz.mydogvr W/linker﹕ libjniavformat.so: unused DT entry: type 0x1d arg 0x165b2
10-04 21:48:15.122  25367-25453/mydog.xyz.mydogvr W/linker﹕ libjniavformat.so: unused DT entry: type 0x6ffffffe arg 0x1e52c
10-04 21:48:15.122  25367-25453/mydog.xyz.mydogvr W/linker﹕ libjniavformat.so: unused DT entry: type 0x6fffffff arg 0x1
10-04 21:48:15.193  25367-25453/mydog.xyz.mydogvr W/linker﹕ libswscale.so: unused DT entry: type 0x6ffffffe arg 0xdd0
10-04 21:48:15.193  25367-25453/mydog.xyz.mydogvr W/linker﹕ libswscale.so: unused DT entry: type 0x6fffffff arg 0x1
10-04 21:48:15.213  25367-25453/mydog.xyz.mydogvr W/linker﹕ libjniswscale.so: unused DT entry: type 0x1d arg 0x38f9
10-04 21:48:15.213  25367-25453/mydog.xyz.mydogvr W/linker﹕ libjniswscale.so: unused DT entry: type 0x6ffffffe arg 0x5a8c
10-04 21:48:15.213  25367-25453/mydog.xyz.mydogvr W/linker﹕ libjniswscale.so: unused DT entry: type 0x6fffffff arg 0x1
10-04 21:48:15.459  25367-25453/mydog.xyz.mydogvr W/System.err﹕ org.bytedeco.javacv.FrameRecorder$Exception: avcodec_open2() error -22: Could not open video codec.
10-04 21:48:15.459  25367-25453/mydog.xyz.mydogvr W/System.err﹕ at org.bytedeco.javacv.FFmpegFrameRecorder.startUnsafe(FFmpegFrameRecorder.java:527)
10-04 21:48:15.459  25367-25453/mydog.xyz.mydogvr W/System.err﹕ at org.bytedeco.javacv.FFmpegFrameRecorder.start(FFmpegFrameRecorder.java:288)
Ok, it looks like we're going to need to debug this on Android, so I've taken some time to hack FFmpeg's log functions and redirect them to Java (or Android's log). There's a new FFmpegLogCallback class in JavaCV. Call the static set() method somewhere during init and let me know what shows up in the log. Thanks!

Samuel
Reply all
Reply to author
Forward
0 new messages