nazirmohd2006 / javacv

Automatically exported from code.google.com/p/javacv
0 stars 0 forks source link

The video codec H.264 cant be found #259

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.I have got data from Android camera(in onPreviewFrame(byte[] data, Camera 
camera))
2.I want to use JavaCV/FFmpeg to encode the data into flv(h.264/aac)
3.The error that I receive with the updated JavaCV 0.3 is that the video codec 
H.264 cant be found. With Mpeg4 and H.263 of such problem isn't present.

What is the expected output? What do you see instead?

Loader.load(com.googlecode.javacv.cpp.avutil.class);
Loader.load(com.googlecode.javacv.cpp.avcodec.class);
Loader.load(com.googlecode.javacv.cpp.avformat.class);
Loader.load(com.googlecode.javacv.cpp.swscale.class);

avcodec_register_all();
av_register_all();

mCodec = avcodec_find_encoder(AV_CODEC_ID_H264);
if (mCodec == null) {
-> Log.d("ENCODE_VIDEO", "avcodec_find_encoder() run fail.");
}

What version of the product are you using? On what operating system?
JavaCV 0.3, Android 4.0.3-4.1.2

Please provide any additional information below.

Original issue reported on code.google.com by guar...@gmail.com on 25 Nov 2012 at 7:29

GoogleCodeExporter commented 8 years ago
We need to build x264 for Android and have FFmpeg link with it... Please attach 
the binaries to this issue if you do it, for the benefit of others, thanks!

Original comment by samuel.a...@gmail.com on 26 Nov 2012 at 1:27

GoogleCodeExporter commented 8 years ago
Hi,

So I understood that ffmpeg-1.0-android-arm.zip hasn't got support for h264.
Reading all the comments I found out that user zhangqia manage to compile 
ffmpeg and x264 and use them with your openCV.

I also tried that, but the symbolic links for the .so files of ffmpeg are not 
recognized by android.

How do you suggest this issue should be overcomed. How zhanggia managed to run 
livavcodec.so from openCV?

Tahnks,
Adrian

Original comment by adrian.d...@gmail.com on 5 Feb 2013 at 9:11

GoogleCodeExporter commented 8 years ago
@adrian If you followed the instructions in the README.txt file to rebuild 
FFmpeg (linked with x264), it should work as advertised... Can you spell out 
what you tried just to make sure?

Original comment by samuel.a...@gmail.com on 5 Feb 2013 at 1:05

GoogleCodeExporter commented 8 years ago
I've managed to compile ffmpeg and x264 and have only .so files but when openCV 
starts, the libjni*.so libraries don't reference correctly the new compiled 
libraries. I get an UnsatisfiedLink error.

How are generated the libjni*.so files and why overwriting libavcodec.so (for 
instance) isn't enough?

Original comment by adrian.d...@gmail.com on 5 Feb 2013 at 2:53

GoogleCodeExporter commented 8 years ago
The API of FFmpeg changes frequently. The current .java files are only 
guaranteed to work with FFmpeg 1.0 at the moment. Are you doing this with 
FFmpeg 1.0? And if so, what error do you get in the log?

Original comment by samuel.a...@gmail.com on 5 Feb 2013 at 11:38

GoogleCodeExporter commented 8 years ago
First of all Samuel, thanks for the quick responses.

Indeed I was using ffmpeg 1.1, I've downloaded a release (1.03 Angel) that came 
from 1.0 (pure 1.0 cannot be found anymore on their site)

I applied your patch and used your ./configure flags, which will trigger a 
compilation error in ffmpeg.c due to some atexit() function. I'm saying this 
just to check that I applied the patch correctly. Because I commented the call 
to this function and everything compiled successfully.

But the error remains:

02-06 10:35:10.338: E/AndroidRuntime(19396): Caused by: 
java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1937]:  1811 
could not load needed library 'libavutil.so' for 'libjniavutil.so' 
(find_library[1200]:  1811 'libavutil.so' failed to load previously)

As I said, I replaced your compiled libraries in the ffmpeg-arm zip with this 
ones and this is what I get.

If you already have a working configuration, I can provide you with the 
compiled x264 so that you can also try the building of ffmpeg.

Thanks.

Original comment by adrian.d...@gmail.com on 6 Feb 2013 at 8:42

GoogleCodeExporter commented 8 years ago
Yes, FFmpeg 1.0 is still there:
http://ffmpeg.org/releases/ffmpeg-1.0.tar.bz2

Original comment by samuel.a...@gmail.com on 6 Feb 2013 at 12:54

GoogleCodeExporter commented 8 years ago
Same issue.

Original comment by adrian.d...@gmail.com on 7 Feb 2013 at 8:08

GoogleCodeExporter commented 8 years ago
And this is with Android NDK r8b? I haven't tried with the newer version, maybe 
they changed something in there..

Original comment by samuel.a...@gmail.com on 7 Feb 2013 at 8:22

GoogleCodeExporter commented 8 years ago
Yes, r8b.
I noticed the compilation error in atexit(). Did you encounter this as well?
If not, then probably the flags for ./configure, present in the readme file, 
are not ok ..

Original comment by adrian.d...@gmail.com on 7 Feb 2013 at 12:13

GoogleCodeExporter commented 8 years ago
Nope, that is exactly how I compile it. You could try to recompile the JNI lib 
files see what that gives as shown in the pom.xml file, something like:

$ mvn clean install -Pffmpeg -Dplatform.name=android-arm 
-Dplatform.root=<path/to/android-ndk-r8b> 
-Dcompiler.path=<path/to/arm-linux-androideabi-g++>

Original comment by samuel.a...@gmail.com on 7 Feb 2013 at 12:22

GoogleCodeExporter commented 8 years ago
I've added support for FFmpeg 1.1 in the repository:
http://code.google.com/p/javacv/source/detail?r=cbc566ba4d15c739a7c7e54f5d6295a7
a5e1c366
So if you're having more luck with 1.1, try it out with this update, thanks!

Original comment by samuel.a...@gmail.com on 10 Feb 2013 at 2:29

GoogleCodeExporter commented 8 years ago
@adrian I see what now. You can ignore those 'atexit' errors. The libraries 
have been created at that point. This is just the linker complaining about the 
executables, which the Android NDK does not support.

Original comment by samuel.a...@gmail.com on 2 Mar 2013 at 7:52

GoogleCodeExporter commented 8 years ago
The latest FFmpeg builds, including Android, now include x264:
http://javacv.googlecode.com/files/javacv-0.5-cppjars.zip
I haven't tested it on Android, but it should work. Let me know if it doesn't! 
Thanks

Original comment by samuel.a...@gmail.com on 7 Apr 2013 at 12:58

GoogleCodeExporter commented 8 years ago
Hi Samuel, congratulations on integrating x264 with FFmpeg!
If I'll find some spare time, I'll definitely try it.
In the meantime, I've compiled and used the x264 separately, especially in the 
ABR mode. If anyone is interested in that .. let me know.

Original comment by adrian.d...@gmail.com on 8 Apr 2013 at 8:13

GoogleCodeExporter commented 8 years ago
Hi Samuel, i've built opencv and ffmpeg with x264 based on the README file, but 
i'm getting a java.lang.ExceptionInInitializerError when i replace the .so 
libraries with the newly generated ones:

04-29 15:40:46.610: E/AndroidRuntime(23057): Caused by: 
java.lang.ExceptionInInitializerError
04-29 15:40:46.610: E/AndroidRuntime(23057):    at 
java.lang.Class.classForName(Native Method)
04-29 15:40:46.610: E/AndroidRuntime(23057):    at 
java.lang.Class.forName(Class.java:217)
04-29 15:40:46.610: E/AndroidRuntime(23057):    at 
com.googlecode.javacpp.Loader.load(Loader.java:338)
04-29 15:40:46.610: E/AndroidRuntime(23057):    at 
com.googlecode.javacpp.Loader.load(Loader.java:319)
04-29 15:40:46.610: E/AndroidRuntime(23057):    at 
com.googlecode.javacv.cpp.opencv_core$CvArr.<clinit>(opencv_core.java:163)
04-29 15:40:46.610: E/AndroidRuntime(23057):    ... 16 more
04-29 15:40:46.610: E/AndroidRuntime(23057): Caused by: 
java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1965]:   108 
could not load needed library 'libopencv_core.so' for 'libjniopencv_core.so' 
(find_library[1200]:   108 'libopencv_core.so' failed to load previously)

i have OpenCv 2.4.5, ffmpeg 1.2,Android NDK r8e and the latest x264 on Ubuntu 
11.10

The exception is thrown when i attempt to call IplImage.create()

Original comment by oti.ke...@gmail.com on 30 Apr 2013 at 12:58

GoogleCodeExporter commented 8 years ago
Oti, it sounds like Android isn't installing the files properly on your 
devices. Try to recreate your project files from scratch, that usually does the 
trick with Android.

Original comment by samuel.a...@gmail.com on 11 May 2013 at 9:30