Java and Video: Never works.. but how does SWT implement the browser?

Hi all,

as so many others I hunted after a way to play a video in a java application across the platforms mac osx, linux, win. The frameworks like Xuggle, JMF etc are either outdated, dead or plainly do not work properly. I now came across a suggestion to use SWT and just load via its browser component a webpage that embedds a video. I tried an example using the windows SWT and loaded a youtube page - it worked flawlessly.
Now there are two questions coming to my mind: what is SWT using that it can display e.g. the youtube video stream without problems and can I use this library on its own to just embed a video and not a whole webpage?

http://www.java-gaming.org/topics/java-media-player/27100/view.html :point:

It would appear to be this? http://www.eclipse.org/swt/faq.php#whatisbrowser. So, theoretically possible to use, but you’d need the SWT binaries. JavaFX’s WebView is similar. You could embed one video by just creating a webpage that has the YouTube embed code and nothing else.

However, unless you have a very particular reason to want to use YouTube, don’t! :wink: Take Riven’s advice and check out that thread. There’s also this. Use whichever works best for you - there are pros and cons of both.

JavaFX supports video playback, and it’s the new hotness in town.

Cas :slight_smile:

Actually, not that different to the old, seen as it’s a wrapper to a locally installed GStreamer! :wink: Having said that, having GStreamer code accessible in any Java install by default would be great and save all that library loading nonsense I ported from Processing. Lets just hope there’s a way to access all the power underneath, as at the moment a lot of it is locked away in JavaFX.

So if you search this forum you will come across a lot of threads by me, since I really wanted this feature and looked everywhere.

Today, the best 3 options are

  • aforementioned YUNPM - which has mild license issues with the codecs, you may have to recompile FFMPEG

  • VLCJ - which is still LGPL, so again a legal issue

  • and gstreamer-java, in this thread we created a player for lwjgl that uses gstreamer and, if you delete the plugin files / codecs, has no license issues
    and it works beautifully

  • there is of course Xuggler which is… very complicated to say the least and not sure about legal problems - and I have yet to see “long” action videos, played and synced with Xuggler

  • JTheora should be the default option, if it didnt suck so hard, since its a pure java way of decoding theora and vorbis, the codecs you would want
    You CAN play theora video alone with it, but video AND audio, just doesnt work anyway near reliable… it will crap-out 8 out of 10 times…

I remind you that JogAmp supports video playback.

Ah yes I forgot, if you dont mind JOGL I would definitely check out JogAmp.

This is in this package, it relies on LibAV and FFMPEG as far as I know. It works fine even under Android ;D

Oh, neat!

Presumably LibAV or FFMPEG?! :wink:

From looking at the code it seems that this doesn’t yet support audio playback? It’s also not bundling the libs, though I assume that’s fairly easy to set up - JavaDoc mentions system install?

At the moment this would seem to be offering less than either the YUNPM or GStreamer-Java solutions. I’m not keen on solutions tied to a particular output either. Direct access to the native video buffers is far more useful across the board. The GPU based YUV conversion is good, but it would still be possible to achieve this using direct buffer access.

Don’t underestimate YUV conversion on the GPU! It makes a massive difference to performance. Mind you, if you reach your target frame rate on your target hardware, who cares.

Cas :slight_smile:

I wasn’t! I’m saying you don’t need to hard link the media player library to the OpenGL library to achieve it.

Ah right.

Cas :slight_smile:

Sven could answer better than me.

It’s wrong. Sven made a demo of it as Siggraph 2012 with an extract of a famous movie and the audio playback worked just fine :slight_smile: I’m really sorry for the lack of documentation. You can run our demos to check it out.

It works out-of-the-box even on a Raspberry Pi and nobody prevents you from porting the code to LWJGL.

I haven’t tried the demos, so sorry if this does work. I was going off the FFMPEG code in the JOGL repo which has the audio code commented out and a big “TODO: audio output”! :wink:

That misses my point, and assumes my only interest is getting video into LWJGL. A useful video library will provide direct access to the video data through a native buffer or alternative pointer. That data can then be used however you want, which may not involve OpenGL at all!

Given that I’ve got GStreamer code that works fine cross-platform, and offers far more than libAV, I don’t have much interest in this myself! However, as a lightweight option it could offer some benefits over the YUNPM approach by linking in-process rather than externally (particularly for seeking / syncing), if at the same time bringing up licensing issues.