In the past days, a marketing agency asked me to develop a video player in Java.
Aside some obvious requirements (play on Windows and Linux), they asked for some custom requirements, like: always start in fullscreen, read the playlist from a remote XML, provide usage statistics, display pictures, display Flash files, etc.
Here are some notes about this work, as the content about it on the web was pretty scarce. It worked in Windows XP, Vista and Ubuntu 9.10.
There is a multimedia platform for Java, Sun Java Multimedia Framework. Works fine, can capture video, but the codecs are pretty old. So I started to search for something more updated.
What NOT worked
FMJ: an attempt to re-write JMF code. Works well to play videos, but it lacks a lot of features, and it’s pretty hard to re-use the existing code.
JFFMPEG: a Java wrapper for FFMPEG. The idea is really nice: if it detects a native codec, it’ll use it. If not, it’ll use the Java version. The problem: it’s missing the Windows libraries. Not a coincidence, I can see they started a company, selling this solution. I even found some steps to compile the missing libraries, but steps are incomplete and hidden in their site.
After gave up in the first 2 solutions, I’ve found FOBS4J, which is a Java based solution, which relies in a FFMPEG wrapper. I.e., very similar to JFFMPEG, but working. It worked with the most common video codecs.
And, better then JFFMPEG, they use Sun JMF as base, which has the source available to download. It’s not that pretty code, but can be perfectly re-used.
Some additional tips:
fobs4j version 0.4.2 (Windows only) it’s really unstable, don’t use it (for me, it always crashed around 5 minutes after start playing any video);
as you’ll see in the fobs4j samples, you’ll be always required to tell it the DLLs/SOs path (use a bash script on Linux, a
JMStudio (the JMF player) code is a bit messy, so you can try make your own player, or if you’re good to read code, you can start with JMStudio code and change to meet your needs;
fobs4j included in JMF is missing some native libraries. If you’ll need to record video, you’ll need them. You can download Sun JMF and then use it’s native libraries with fobs4j.
Hope this will help someone with the same problem!