Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Java Media Framework, V4L (and V4L2, kind of) on AMD64
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
estar
n00b
n00b


Joined: 01 Dec 2007
Posts: 20

PostPosted: Sat Oct 11, 2008 2:02 pm    Post subject: Java Media Framework, V4L (and V4L2, kind of) on AMD64 Reply with quote

In the words of Tom Lehrer, this might perhaps be useful to somebody someday, in a somewhat bizarre set of circumstances. I’m posting it here just in case...

I wanted to try the Mercury IM client, which is written in Java and uses the Java Media Framework (JMF) for video capture. JMF does video on Linux via a native library which uses the V4L1 API. Gentoo has JMF in binary form as dev-java/jmf-bin, which is nice. The native .so that interfaces with V4L is built for the x86 architecture, which is not so nice. I use amd64 and it didn’t work.

Well, fortunately for me, Sun had released the source code to JMF, so I decided to build the whole thing. :) Except the source code has at some point disappeared from Sun’s site, so to get it you have either to find the file on Google or to ask in Sun’s forum for people to mail it to you. I chose the first option, the file I found is (with SHA1 sum):
Code:
d5639d6e1251be4f7f643ef3e0f5278946a59790  jmf-2_1_1e-scsl-src.zip

The source code is missing a bunch of (proprietary? patented? embarassing?) libraries that appear in the Makefiles; I copied the missing stuff from jmf.jar as installed by dev-java/jmf-bin-2.1.1e-r2.

I used Sun JDK 1.6.0_10-rc2 and gcc 4.3.2 to build JMF. I have noticed no external dependecies other than standard C headers and kernel headers.

Build instructions:

  1. Obtain jmf-2_1_1e-scsl-src.zip, verify the checksum (I’ve no clue if my copy is authentic, though) and unpack it in some empty directory.
  2. Unpack jmf.jar from dev-java/jmf-bin in some other directory.
  3. Patch the JMF sources with http://paste2.org/p/85416
  4. Edit taint.sh and set paths to match the ones where you unpacked stuff.
  5. cd to doc/buildinfo in the source tree, edit buildjmf.sh-template and change JAVAHOME and JMFHOME to match your paths.
  6. Code:
    tcsh buildjmf.sh-template
    If you get errors at this point, fix them, then run the script again. Once you’ve fixed them, consider reporting them here. :)
  7. Now you have a hopefully working JMF in build/linux/image, so cd to build/linux/image/lib.
  8. Code:
    LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH CLASSPATH=`pwd`/jmf.jar:`pwd`/sound.jar:`pwd`/mediaplayer.jar:`pwd`:$CLASSPATH ../bin/jmstudio
    If JMStudio doesn’t work, fix it. :P If it works, open the jmfregistry app and let it detect your hardware. Don’t forget to commit the changes; also, it may want to write to /usr/share/jmf-bin/jmf.properties... If all that works, try capturing video in JMStudio.
  9. Replace jmstudio by whatever you actually needed JMF for in the first place.


Note that running make clean in build/linux will delete the stuff taint.sh copied. So run taint.sh after make clean before building again. :)

Also, my camera is supported by uvcvideo, which is V4L2 only. I used libv4l-0.5.0 from http://people.atrpms.net/~hdegoede/ (see also this post), which translates V4L1 operations to V4L2.

  1. Download, unpack, make, sudo make install (stuff goes to /usr/local/lib).
  2. Code:
    LD_PRELOAD=/usr/local/lib/libv4l/v4l1compat.so LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH CLASSPATH=`pwd`/jmf.jar:`pwd`/sound.jar:`pwd`/mediaplayer.jar:`pwd`:$CLASSPATH ../bin/jmstudio



This seems to work for me so far. uvcvideo from hardened-sources-2.6.26-r2 was buggy, so I grabbed the uvcvideo sources from SVN, which happen to work.

Changes made to the JMF code are mostly renamings to avoid clashes with the new enum keyword in Java and changes from int to long for pointer values. This is the part that makes stuff fail on 64-bit (Java ints are too small to hold pointers) and if you need other JMF classes which segfault or fail to work, it’s something you should check. I am not at all sure I got all places where it matters.

TODOs (i. e. exercises for the interested reader):

  • Get Sun to release the JMF code AGAIN, this time hopefully under a more liberal license than SCSL. ;)
  • Fix JMF’s build system, add things that Sun’s developers wanted to add but didn’t (e. g. bilinear scaling...), fix bugs.
  • Make ebuild.
  • Investigate remaining SIGSEGVs.
  • Alternatively (preferably?!) make and maintain FMJ ebuilds and port everything. :)


Sorry about the long post.

Edit: made new patch with a few more changes, because I’d overlooked something that caused Mercury to crash.

Also, to make Mercury use these libraries, I substituted the .so and .jar files built as above for the ones included with Mercury. It works and has video support now. :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum