I am making my first steps into java game developing, and I have kind of a prototype of a game. I wanted to add a small intro video (and cut scenes in the future) before the menu and the game launches, and I am finding that is not easy.I have read about JMF, and about javaFX and Xuggler to add a video file... but everything looks quite complex, and not everybody looks happy with their solutions.

So, my question is, how do you add cutscenes to your games? Of course if it is something simple/small I can directly animate the frames, as I do with sprites, but I guess that's not the solution for comples/long cutscenes. To be able of add a video file and play it before the game, or en between will be awesome...

I don't want to re invent the wheel and I want to solve this as easy as possible! I guess most of you have wanted to add some cutscenes or intros to your games...

Note remarkable lack of video in Java based games. This is because... Java video has been stunningly ignored for the past decade. It is not at all trivial to try and do. If this is your first foray into Java game developing I'd simply give up on this particular thing now and carry on with the rest of your game, which will probably have you pulling your hair out anyway. Come back to it when the game is finished!

Look at FreeCol, it uses a cutscene. There is an attempt of providing build-in video support in JogAmp, it uses FFMEG and libAV under desktop environments, something else under Android. Please ask Sven to explain to you how to use it, rather post your question on the official JogAmp forum. Best regards.

Edit.: Someone here succeeded in using JMC (from JavaFX).

Edit2.: In the worst case, you can try to use a command to run the player.

Hey Cero, yes I have read your threads about this, and that's how I know it is hard.

Well the point it is that I really need cut scenes... I was making a point and click adventure, so the cut scenes were supposed to be a very important part. But if it is to difficult to make it work, well, I have another projects in mind, so I can start making another videogame that don't need any video. And let's see if in the future I want to make the point and click adventure in java or not!

Hey Cero, yes I have read your threads about this, and that's how I know it is hard.

Well the point it is that I really need cut scenes... I was making a point and click adventure, so the cut scenes were supposed to be a very important part. But if it is to difficult to make it work, well, I have another projects in mind, so I can start making another videogame that don't need any video. And let's see if in the future I want to make the point and click adventure in java or not!

Of course there are many popular point and click without video... But I can understand that you want video in story based game.Basically VLCJ works. Its just a little hassle to include everything for every platform. But VLC works on every platform, and its very reliable.Only minor problem is, which might disappear soon, that VLCJ is still GPL, which forces your whole sourcecode to be GPL.Even if that happened, nobody cares about source code anyway...

I just decided to give it a shot: using VLC (not VLCJ) to play the audio in realtime, and streaming the video frames to 1 file, which is continuously overwritten. VLC takes care of the syncing of video/audio. The only thing the Java app has to do is poll the dump-file, read it, and display it.

Obviously the disk I/O becomes the bottleneck, so to playback HD @ 25fps, I needed the dump-file to be on a RAM-disk.

It's only 150 lines of code:http://pastebin.java-gaming.org/54a6b0d341cIt could be a lot shorter, but I decided to use 3 threads: one for I/O, one for decoding, one for displaying. This resulted in smoother playback. It effortly played back any media file I threw at it.

Because Java's ImageIO.read is rather slow for PNG and JPEG, I used BMP for the dump-file for best performance. javaw.exe used about half the cpu cycles vlc.exe used, which to me seems good enough.

According to the commandline options, we can provide function-pointers, so VLC can simply call a C function, providing the pixels, which we can copy/map into a texture, or an awt image. To me, this seems like something you can code in a rainy afternoon, so why are we all giving up on 'java video' ?

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

It's full of dependencies anyway, so in the current state it's useless. The requirement of a ramdisk adds insult to injury, don't waste your time on it

It would be acceptable if Windows natively supported the creation of ramdisks. I'm using ImDisk (freeware) to create a 8MB ramdisk that holds the file. It's still inefficient, as it simulates a NTFS partition, which adds quite a bit of overhead, so it's never going to be as fast as IPC (inter process communication).

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

Xuggler looks like a good choice for Java video. Xuggler and FFmpeg are both LGPL (unlike both VLC/VLCJ which are GPL), seems easy enough to setup and have seen it used in a few big Java projects (JPCSP, Wakfu, jMonkeyEngine3, etc).

it ain't, anymore. It's LGPL now.So Mark Lee said to me its probable that he is going to change VLCJ's license too

Oh, thats good. I may use VLCJ later too, if it is LGPL, I really like it. But I dont need to, currently anyways, cause I'm not having much story in my game right now (And I'm not too god in making movies anyways )

Has anyone successfully tested VLCJ on Mac/Linux? Last time I tried building from source I got a lot of unexplained linking issues.

Well you know, its not that easy.The idea is to have VLC installed and VLCJ links to this "vlib".However thats complete crap right there, since you cannot force a user to install VLC or expect that they have it installed.So what you do is, ship everything you need with your game and link it yourself, like private JVM.So I have a vlib folder, similar to the lib folder.

1

System.setProperty("jna.library.path", "vlib");

and in the vlib folder you need to have specific files like libvlc (per platform) and the codecs. (of course only codecs that you are allowed to redistribute and use, meaning theora and ogg - not ALL codecs)

So its copy work - but once done, it works.I haven't tried that hard to get it to run, but all you have to do is to copy from the installed folder on a mac and on linux, the files that you need.On linux I just couldn't find those all that quickly so I couldn't try it yet.Mac is officially supported by VLCJ and Linux should be even less of a problem. Since VLC works so good on it.

Well guys, thank you very much for the help... this is really an awesome community!

I think I will just not do videos for the moment - I will keep programming and, on the end, when I know more java and I have a semi finish game, then I will confront the video issue, probably with the help of vlcj, that sound quite good.

I know this guy - he doesn't like JRPGsGo figure...I love MGS4. I watch 20 hours of cutscenes for a decent story giving context to gameplay.

As you have more story you need more exposition.The more it is the harder it is to do simply ingame.Also 2D and 3D are totally different stories. A 2D game doesnt even offer the option to convey complex scenes ingame, even if you wanted to script it all.

I could say more... but I could write a whole paper.Imo story-telling is, to me, the most important part of a decent immersive game. (Actually to all media: movies & books alike. Even music should strife to have meaningful lyrics, or none at all.)Of course I say this while games like COD, Farmville, Wii Sports are top-selling; but hey Final Fantasy games aren't doing too bad.

But even in games where unique gameplay plays a predominant role, story and characters make it great: Portal 2 would be boring without story and charactersI only think highly of games which had much emotion context...Thats why people say FF7 is the best game ever - everyone has sincerely touched by it. And they can still recall those feelings.And all those shooters already look the same now, forgettable; Remembering back, it will all be a blur.

I also directly disagree with his philosophy that gameplay should stand on its own - I'm just not a fan, I need to care, I have no ambition without emotions.Would like to point to Deadly Premonition aka Red Seeds Profile: Many say its utter crap and many say it brilliant. It has a horrible gameplay and a great story and characters.

Well the point is cutscenes != storytelling. I agree with that. I don't know if the guy likes JRPG's or not, but he goes on to say that dialogues in RPG's are fundamentally different from cutscenes. For instance, dialogues in RPG's usually give you choices along the way ( This is a good thing ).

The issue with cutscenes is that it disconnects you from the game. Instead of being part of the story, you're sitting on the sidelines observing it.

I suggest skipping cutscenes altogether and focusing on storytelling. In general, this means playing out a scripted scene in the game engine/world where you're still in control of your character. Simple and effective and a lot better than cutscenes imho.

[EDIT]: Storytelling in video games can be so much more than simple 1 dimensional movie effects.

In general, this means playing out a scripted scene in the game engine/world where you're still in control of your character. Simple and effective and a lot better than cutscenes imho.

You can certinaly try in a 3D game. in 2D, I dont see how you would do that, without sacrificing complex scenes.

Overall it is possible... Egoraptor also says that if things happened to you directly, the impact is much greater.However, at least for now, I'm not as arrogant as to believe I could change story telling in games in a way the industry has never thought about and innovate it and stuff. Therefore I lack game making experience; and story telling experience for that matter.

You can certinaly try in a 3D game. in 2D, I dont see how you would do that, without sacrificing complex scenes.

Certainly it wouldn't be much harder than creating a FMV from scratch. I'm not sure what world you live in where animating FMV cutscenes (especially higher poly 3D scenes) is easier than programming some simple game logic.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org