Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 19, 2013 2:08 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Slick2D video playback
PostPosted: Tue May 01, 2012 9:30 pm 
Offline

Joined: Tue Apr 05, 2011 12:34 pm
Posts: 6
Location: Scotland
Ok I'm really stumped.

I kind of imagined a 2D engine to include support for 2D videos before it included support for particle physics and sounds but whatever - this doesn't seem to be the only place suffering from lack of video capabilities. Going through pages of search results I can't seem to find a good solution to play videos in Java. They're all implementations of things like Windows Media Player and VLC with buttons and compatibility issues. D:

Is there no way to just do something along the lines of:
private Video vid=new Video("somefile.mpg");
then vid.play() like we do with Sound, Music and Images? :( (Obviously with some kind of restriction on video formats accepted by the engine.)

Either that or is there some way to do it with a bytestream? I see all these, file input streams, data input streams, buffered input streams etc. - Does any combination of that allow for video playback xD?

Seriously, I'm stumped - all I wanted to do was play a little logo animation (with audio) at the start of my game. :(

Anyone point me in a better direction than the 4 billion I've attempted thus far xD?

(And don't say Xuggler because I can't for the life of me find any way to actually install that. :P )


Top
 Profile  
 
PostPosted: Tue May 01, 2012 11:25 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1467
Basically, don't count on it... It's been tried by everybody and their mother, and nobody has an easy solution yet.

Quote:
I kind of imagined a 2D engine to include support for 2D videos before it included support for particle physics and sounds

Slick is a 2D game engine; particle physics and sound are much more common for games than multi-format video playback.

The closest I've seen to a simple solution with OpenGL is using VLCJ. You'll need to know a fair bit about video decoding and OpenGL to get things running smoothly, let alone with slick.
http://www.java-gaming.org/index.php?topic=24846.30

If all you're doing is playing "a little logo animation," though, video playback is not the best solution. What does your animation look like? How many frames is it? Chances are you could get away with a sprite sheet animation.


Top
 Profile  
 
PostPosted: Wed May 02, 2012 8:31 am 
Offline
Regular

Joined: Thu Sep 22, 2011 4:39 pm
Posts: 165
Location: Belgium
i've prototyped before in javafx and they have a nice vid playback system
maybe you are able to link this to slick.. ?

http://docs.oracle.com/javafx/2/media/overview.htm#CJAHFAHJ


Top
 Profile  
 
PostPosted: Wed May 02, 2012 7:23 pm 
Offline

Joined: Tue Apr 05, 2011 12:34 pm
Posts: 6
Location: Scotland
I tried looking into a solution for VLCJ but it said I need to know what VLC version people would be using... I didn't even realise there "were" different versions, and I'm pretty sure the vast majority of people don't have VLC installed anyway. :(

This is literally all I'd want at the start of my games:
http://www.soharix.homestead.com/soharixintro.mpg
(And as I try that link I realise not even Google Chrome can render it properly...)

Lol, why is video decoding such a difficult process? - Why haven't we nipped this in the bud yet... D:

Video's have only been around since pre 1950s. D:<


Top
 Profile  
 
PostPosted: Wed May 02, 2012 8:00 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1467
Video decoding is a pain in the arse, short and simple. And there is a lot of licensing issues regarding different codecs that limits people from distributing them as open source software.

Convert your video to still frames using Photoshop or something, then pack them into a sprite sheet and voila. With only a bit more code/photoshopping, it has the added benefit of: reducing your game's distribution size and greatly increasing visual quality (lossy format to lossless).


Top
 Profile  
 
PostPosted: Wed May 02, 2012 9:02 pm 
Offline

Joined: Tue Apr 05, 2011 12:34 pm
Posts: 6
Location: Scotland
Quote:
Convert your video to still frames using Photoshop or something

I wouldn't know how to do that properly... D: (I also only have Gimp)
(And I'd lose the audio track)


I have managed to get VLCJ working... horribly... but when I build my .jar and pack everything with it, it simply refuses to open properly. The Slick2D window comes up but is called "Game" then it just closes. (And being that .jars run in windows, I have no idea how to get at a console output - I narrowed it down with comments to being something to do with the instantiation of the MediaPlayerFactory but can't find out anything more than that. :( )

It works fine when run from Netbeans. :(


Top
 Profile  
 
PostPosted: Wed May 02, 2012 9:07 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1467
If you can't figure out how to run a JAR from the console, then decoding video frames into an OpenGL texture is probably well out of your league...

Running a JAR from the console should be the least of your worries. But Google will help you do that. ;)


Top
 Profile  
 
PostPosted: Wed May 02, 2012 9:32 pm 
Offline

Joined: Wed May 02, 2012 9:20 pm
Posts: 2
If I remember correctly, a free program called Virtualdub has the ability to convert a video into several PNG images. This wouldn't preserve the sound, so you'll have to run that separately, and it may be a little hacky to load however many tens of images this creates -- it might be a good idea to combine the resulting images into one giant BigImage and use that as a spritesheet of sorts, moving it upward by exactly the height of each frame per update.


Top
 Profile  
 
PostPosted: Thu May 03, 2012 10:10 am 
Offline

Joined: Tue Apr 05, 2011 12:34 pm
Posts: 6
Location: Scotland
Quote:
If you can't figure out how to run a JAR from the console

I can make the .jar run from the console but it doesn't put any of the output into it that I'd be expecting to come up in the Output window in Netbeans. :(

All I want to be able to do is see why it's having issues with the MediaPlayerFactory D: - Because if I can solve that, then I've got a .wmv playing in a .jar xD (The .mpg I tried started but froze after a second or 2 D: )


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group