Video playback in jME3

So, com.jme3.video is deprecated as I see.



What now ?

If I’m correct, it used Cortado before - which has its problems of skipping / desync, blah…

Create a new jme3 video playback api and contribute it :smiley: Actually somebody started something based on gstreamer but didn’t finish it… I don’t know if gstreamer would be the best solution anyway tho. Basically you just need some library to decode the video, then draw it to a texture. Syncing video and audio is the hard part.

I’ve been using so many by now:



Cortado: got it working properly, with 2 files audio and video, syncing here is difficult as always, but at least this works and doesnt skip/stop

QT_java: well its deprecated

JMF: yeah… no

JavaFx2-video: nice, but the only codec, now, is Vp6 which sucks ass

VLCJ: Very nice. However there are legal issues and practical issues, shipping codecs, GPL’ing your source.

Xuggler: Yeah that’s were the good stuff is, but I’m not pro enough to make it work.



So right now I’m between Cortado and VLCJ…

JMF: yeah… no


LOL :D


VLCJ: Very nice. However there are legal issues and practical issues, shipping codecs, GPL’ing your source.


Yes, VLCJ would be quite tough to get operating correctly.. Especially since VLC needs to be installed on the target :/

Xuggler: Yeah that’s were the good stuff is, but I’m not pro enough to make it work.


I could be misremembering here, as the last time we seriously stepped up to the plate (see below) with this was January, but didn't Xuggler need some extra software installed as well? If this is a truly portable solution then it may be worth looking into again, they had superb documentation and seemed fairly active (it was an open-sourced component of a commercial project)

http://vimeo.com/19295672
FYI, this was Cortado in jME2
Especially since VLC needs to be installed on the target


You can just copy the dlls / .so files and codec folder. But legal issues with shipping the codecs...

didn’t Xuggler need some extra software installed as well?


I've never got it to work, but I don't think so; you are probably thinking of codecs again, which, yeah, is the same issue.
Yeah Caspian Prince also says Xuggler is the video lib. But even Xuggler users have sync issues; and for me it's above my head.
I just need: play video here, go.
I just need: play video here, go.


Heh, if only everything were that simple ;) Sync issues are almost always going to be something that needs to be overcome when you're dealing with a loop that has extra burden on it (like one that renders OpenGL graphics under the auspices of an engine called jMonkeyEngine), but nothing is impossible!

The other, kind of crazy, possibility is taking the berkelium-java wrapper, and painting that on to a texture. You wouldn't need to worry about handling input or anything since it would just be a web page that you go to and has the playing functionality embedded on load.

@normen, I keep coming back to berkelium and saying "man, wouldn't that be awesome?" Now that I've got a Windows box set up I might give it a shot and worry about recreating the headers and recompiling for OSX/Linux later..
@normen, I keep coming back to berkelium and saying “man, wouldn’t that be awesome?” Now that I’ve got a Windows box set up I might give it a shot and worry about recreating the headers and recompiling for OSX/Linux later..

Due to the non-working rating plugin I'll do it verbally: "Thumbs Up!" :D

Hi there,



I would like to get this working as well :slight_smile:



And I found something: It’s a sample code to get VLCJ working with JME:

http://code.google.com/p/vlcj/wiki/JMonkeyEngineExample



Well it seems it’s not synchornized.

But I am going to try this out now anyway …



Good luck on the other projects :wink:

@finomosec I don’t suppose you ever gave VLCj a try? I had a look at it again now and it appears both the VLCj project and JNA are alive and well.

Unfortunately it’s under the GPL license, so we could only add it as a plugin. Still worth exploring.

Actually i have a far worse/ simpler solution ^^

Use the jfx browser render it to texture and display in jme, load a html5 video webpage :slight_smile:
http://hub.jmonkeyengine.org/forum/topic/jme-jfx-integration/

There is currently no way to send inputs to send key/mouse envents to the webpage, but for displaying video its quite nice so far.

1 Like
<cite>@erlend_sh said:</cite> @finomosec I don't suppose you ever gave VLCj a try? I had a look at it again now and it appears both the VLCj project and JNA are alive and well.

Unfortunately it’s under the GPL license, so we could only add it as a plugin. Still worth exploring.

Actually i tried VLCj back then (2012) and it worked well.

The only problem with it is, that you can not package it easily so it runs on all systems.
You would have to install it and adjust settings and environment variables each time to get it working.

Hmm I see. Well dangit, that kind of sucks. Sounds like JavaFX might very well be the most cross-platform friendly approach so far then.

Yo!
Any news on this one? I’m also looking for a way to do video playback on jme, I’ve looked into that vlcj code sample but it looks like it had a lot of revisions since then, so I have no idea how to make it work with the latest version of vlcj.
So if anyone could at least show how to do it with the latest vlcj, it’ll be very much appreciated. =D

@totiman9 i have found JavaCV to be very good at it, without audio, though. But I have tried playing back a movie with JavaCV and sound with standard JME audio playback feature. However, I have tried playing movies about 1 minutes long and there was no synchronization issues, although maybe 1 minute is not too much.

But really, idk how could a sync problem could happen since audio is always played at correct speeds since otherwise, pitch or length of sounds would be affected which is not tolerable for audio. And when playing video, you have the FPS from the file metadata, so you always know, when does any given frame start and how long it must last and can either drop frames or quickly take more than one to compensate any temporal incoherence… The overall playback code with JavaCV was something about 2 pages and featured play/pause/stop/setFile…

However, I am very interested in playing sound from a movie file too. The recommended way for JavaCV is to use JavaSound and I doubt it can extract sound from movies… so I am looking for some solution on that too. Xuggler worked but it is a bit cryptic and not easy to control the playback. So I am researching vlcj now too… sure it can play sound?

was it difficult trying to get javacv to play in jmonkey? I’m looking at their java code page and I dont see a direct or easy way to do it. Ive been looking into trying to play a video in jmonkey for the past couple of days now, and I dont even need sound with my videos. just trying to play the video >.<

@icamefromspace: here you can see my implementation. Starting from JavaCV v 0.4 or so it simply works when you add the jars to the project. The code is in Scala, but I think it is easily readable in that part. The VideoImageOCV is one which uses JavaCV. There are also other video images, but the JavaCV one works the best.

BTW, I have just found out that JavaCV allows for grabbing sound too! However, the technique is different and there is no tutorial and currently I have asked the question on the google group, but looks like there are people who already successfully use it and are happy with it.

EDIT: oh, in that repo there is only DirectShow Java implementation besides the JavaCV one, and it does not really work well… oh well… I also admit the code quality is far from best, sorry.

2 Likes

@noncom Dude, thanks a lot for putting this up =D. I’ve tested it and it works great, it has a lot of dependencies though.
Performance is also good, I’m running at almost 30fps on integrated graphics.

For others who’d like to test it too, here’s the java code that I’ve sort of rewritten from noncom’s code for convenience:
VideoImageOCV.java

Just make sure you have all dependencies.

1 Like

just with the caveat of the gpl license on the javacv project. (meaning you’d have to release the source code of your game to comply the gpl license).

it does indeed work though.

not sure if there could be a legal workaround here, like releasing your video playback code as a separate project/jar so you dont have to release the source of your game. never tried such a thing personally.

Isn’t OpenCV under BSD? Maybe if you can do this with OpenCV’s Java API instead of JavaCV? :-?

@totiman9: @icamefromspace: glad it worked!

But, right, the license…

Actually JavaCV is far more and bigger than just a wrapper around OpenCV. OpenCV and its Java API, ummm… isn’t that good. For example it does not integrate FFmpegGrabber and isn’t really sutable for video playback. I think that the best solution is to ask Samuel Audet, the creator of JavaCV either by email or in JavaCV google group. I remember him talking that he’d be glad to get examples of different uses of JavaCV to put them in JavaCVs examples folder. You can propose of sharing your code and even an example project - the JavaCV integration with JME - and talk about the license.

I have been into alike license issues before and them are mostly solvable. Usually things can be settled by talking with the author since really many people are programmers and not lawyers and just choose some kind of license but they are not so zealous about it. Maybe it is possible to make some agreement with Samuel for integration with the JME projects and make it usable by all the JME community.

For example, recently I have released a free Leiningen plugin that used JarClassLoader by JDotSoft for Clojure community. Some people pointed to the license issues, the JarClassLoader was GPL while the prevailing majority of Clojure projects are ECL, same as Clojure. That almost prevented the ability of legal use of the plugin by the community. I contacted JDotSoft and the author was very kind and helped me to organize the license section and we got it settled.