Is there any chance to use it without installing JMF? E.g. can one make a jnlp that starts on machines without JMF?
Well you can include JMF / FOBS etc. in the webstart. You can use a premade JMF properties file, but right now there's no premade FOBS crossplatform package (because the FMPEG dll/so/jnilib is so huge perhaps). And Sun, well they're Sun. "Installing" JMF (if you go option 2 or 4+2) is pretty painless, it's just extracting some libs.
The registering of the renderer I made is done manual for now, but mostly cause I didn't find any way to specify at runtime which one should be used. I'm sure that's possible though, I just didn't find it yet. But either way, it's possible to do a webstart. As for legal: Sun allows redistrubition (even in parts) of JMF (eg FOBS does this).
And:
release 0.0.2. I spelled my name wrong (true story) and some other textual changes.
release 0.0.3. Option for framesync left on in example by accident.
Great work llama. It seems pretty complicated for people to be able to add video to their games though. I wonder how difficult it would be to make it as easy as jME-Physics to include as an extension to jME? If we could do that I think it would make life much easier for people interested in using JMF. Also, if I wanted to make a WebStart version that had this all included, aside from the video file and all the other stuff that is already required for jME how much extra download is required for all of this?
darkfrog
Yes… however, I'd like it if people test it like this first. Especially on linux and mac. And also test some different input sources like webcams.
It's only the setup that's complicated for now, webstart will be easier, once I find a consistent cross platform way to do setup. (problem is I lack platforms). If you want to help me with that, you can send me the jmf.properties in the JMF directory after registration (mention wether you used FOBS or Suns install, gimme both if you feel really helpfull), so I can see what renderers are available on other platforms.
You can already make a webstart yourself, just do the registration and stuff,and jmf.jar is just a lib like any other as long as you include the generatated jmf.properties. Again, problem is it won't work on all platforms.
Now don't let the big document scare you. If you want to test this, it's not rocket science. Copy some sources, include some libs, and then point-click,enter-a-class-name, press commit and you have it working.
I mainly did this cause people wanted to start developing with video/jme. Well now you can… Now I'll need your help if we'll want to turn this into a crossplatform library. (I'll also try to get my patch in FOBS). The only longer term problem I can see is that including FOBS (if you're gonna use that) in webstart will add quite a bit of size (6,45 MB .dll). However, you should be able to do a recompilation for that, to only include the codecs you need for your game. JMF itself can be cut down to under 1 MB.
That, and for audio we'll need a jME plugin to have 3D sound and such (and JavaSound is the only other real crossplatform solution, which is unreliable). Also, I'm looking at a way to cache (small, I assume) video files completly in RAM.
Okay, I'll try to get some tests done on Windows and Linux with this in the near future and send you the info.
That's a pretty large addition to a game, but if you're sticking a video into the game anyway 6 meg is probably nothing in comparison with the media you're adding. :o
Can we not use JMF to output the sound directly into jME's sound system?
darkfrog
Yes that's what I'm suggesting. Not sure how well suited jME's own sound system is at the moment for handling/streaming different sampling rates and such (it mostly seems to be meant for directly decoding ogg/wav), though I haven't taken a closer look yet. Sound also seems a bit more complex with JMF. Advantage would be, support for much more audio (only) formats in jME too.
You could however, always split the video and audio into different files, an use jME's existing OGG support if you really had to. I also think there are some use case where you don't sound anyway (like an animated skybox, or an animated planet with cloud layers and such).
The big problem with that is the probability of them getting out of sync is drastically increased. :-p
darkfrog
I assume you're using FOBS. FOBS uses the ffmpeg code for reading files, in a way that's a good thing (ffmpeg is rather optimized for this). The bad side is, I don't think you'll be able to read from inside a jar file like this. You could consider extracting the video files to the temp dir from the jar.
This is cool, any new thoughts on it ??
Well, it's ready for use. If linux(/mac) people tell me what their result are, and send me their properties files I can try and make cross platform use a little easier.
Sorry… I'm not much of a JMF expert at all.
Did you profile to see what takes up the memory?
S
FWIW, I'm working on a framework for supporting video in jME without the need for additional libraries such as JMF. Currently it only supports RoQ, but the insides are nice and transparent and completely maintainable by us. Perhaps we could even merge the two efforts?
I think your solution of using a format that gives you complete control over decoding process is better to be honest. And it's pure Java right? I made this cause there was some discussion on the forum about it, mostly to show it can be done and give others a starting point if they needed.
Maybe after you're done we can see if there's still some benifits to my code. It does handle loads of formats, and it can do webcams, etc. I'm also curious how you support audio (mostly because JFjr leaves some things to be desired in that area). If there is, maybe we can work towards a common interface a la Text/Text3D, but for now I'd just focus on what you are doing yourself. The "interface" I have here is a mix of JMF and kludge, so you won't need any inspiration from that anyway.
I'm S
@llama: Cool, I'll give a heads up as I get further along with things. I'm still agonizing a bit over audio myself, but the video is running at a nice rate. If you want a peek, I put a few pics up on my blog a week or two ago of the thing in action.
@sthorsen:
You can use Yourkit, either the trial or the EAP (early acces).
http://www.yourkit.com/
http://www.yourkit.com/eap/index.jsp
That's what I use.
Netbeans and Eclipse 3.2 (you have to use the Callisto update site tough) also have built in profilers. (Don't mix Eclipse's profiler and Yourkit though).
Inspired by your post I'll also look at it a bit myself.
@renanse
Yeah, I already saw the blog pics a while back, it's looking good. I hope I'll finally have some time soon to check in the rectangle texture stuff, that might be useful for your videos too.
Nice! Thanks for the links
I can't find any leaks when I use
p.close();
p.deallocate();
The only thing left behind is the buffer the video is rendered into, but only as a refernce to a static field. So each time you make a new player it's overwritten.
I did notice however that when you leave a reference to a javax.media.Player it does take up some room (despite the deallocate). So make sure you don't have any references to it. It's in JMFVideoImage, so either change that to null the reference, or make sure you don't have any references to it after you use it.
eg in my local copy I updated the stopMovie method:
synchronized public void stopMovie() {
try {
jmfplayer.close();
jmfplayer.deallocate();
jmfplayer = null;
System.gc();
} catch (Exception ignored) {
}
}
And yes, I'm aware JMFVideoImage isn't very nicely designed. If you made any more changes to it to make it more workable than it currently is (I noticed you added getJMFPlayer()) feel free to post them here.