Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (527)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  UARG! JMF video playback ... does it work in any way!?  (Read 7259 times)
0 Members and 1 Guest are viewing this topic.
Offline Serethos

Junior Devvie




Java games rock!


« Posted 2010-01-10 20:12:41 »

There is my simple task on playing _any_ video format, which I am able to encode for free.
So I tried JMF 2.1.1 and Java 6 ... but it throws only Exceptions of not supported format, not
supported frame rendering or things like "Unable to realize com.sun.media.PlaybackEngine"
although I really tried to encode in formats. which are given for the cross platform version
given here:

http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/formats.html

So can anyone describe me a way to encode a video (better: to convert an existing one with
a tool) so it is played by JMF? Or is there any (platform independend!) alternative?
Offline moogie

JGO Knight


Medals: 13
Projects: 6
Exp: 10 years


Java games rock!


« Reply #1 - Posted 2010-01-10 21:11:17 »

<cheap shot>

well, if it is any format then just "encode" each video frame as an png and then for play back just read in a reasonable buffer of frames and then display them... not elegant but is cross platform independent Tongue

</cheap shot>

I cannot help you with JMF... perhaps you can attempt to use the native os file association to load your video in the native video player by runing an external process?
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #2 - Posted 2010-01-10 21:16:09 »

<troll/> Jerry-rigged Media Fcuk-up  Grin

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 834
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2010-01-10 21:20:03 »

I actually got JMF to work one day, with a webcam.

It was so much slower than the native app... 15fps (100% CPU load) vs 60fps (5% CPU load)

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

Junior Devvie




Java games rock!


« Reply #4 - Posted 2010-01-11 14:24:23 »

That really can not be the actual situation! Uaaargh!
I clearly remember the last time I was active in game development (about erm 6 years ago?). And I knew that
JMF was only a bunch of problems. Now I thought that the media support should have matured enough so that
it would be no problem of rendering a video of a common format in Java!

So do we have to forget about video cutscences in Java games (really?!)?
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #5 - Posted 2010-01-11 14:28:57 »

you can pretty easily use something like VLC Media Player with java, worked pretty well the last time I tried it. (just grab the hwnd and embed into a java app)
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 834
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2010-01-11 14:58:53 »

Now I thought that the media support should have matured enough...


JMF is dead.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline gouessej
« Reply #7 - Posted 2010-01-11 15:29:27 »

Have a look at JMC and especially JMediaPane.

Offline Serethos

Junior Devvie




Java games rock!


« Reply #8 - Posted 2010-01-11 15:45:02 »

Thanks for the replies on alternatives. Can you tell me if the mentioned player components are
platform independend - so no native libraries are used?
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #9 - Posted 2010-01-11 16:40:21 »

Thanks for the replies on alternatives. Can you tell me if the mentioned player components are
platform independend - so no native libraries are used?

VLC Media Player is totally platform dependent Smiley
but it has builds for all the main architects.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Serethos

Junior Devvie




Java games rock!


« Reply #10 - Posted 2010-01-11 16:53:21 »

Perhaps im searching a bit clumsy .. but where can I download the libraries for JMC?
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #11 - Posted 2010-01-11 17:19:14 »

came across this nice article might be worth a read http://www1.siconet.at/Kastna/wordpress/?p=609
Offline noblemaster

« JGO Spiffy Duke »


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #12 - Posted 2010-01-11 20:48:51 »

That's great! I always wondered what to use for video on Java  Grin

Offline GKW

Senior Devvie




Revenge is mine!


« Reply #13 - Posted 2010-01-11 21:05:26 »

Xiph.org has a pure java implementation of the Theora codec available in a signed jar.  It's royalty free and is playable, but still drops frames, on my crappy laptop.


<a href="http://www.theora.org/cortado/">Cortado</a>
Offline tom
« Reply #14 - Posted 2010-01-11 21:13:17 »

came across this nice article might be worth a read http://www1.siconet.at/Kastna/wordpress/?p=609
Anyone knows if it is possible to use FOBS to grab the frames of the video. Have been looking for a way to do video textures.

Offline noblemaster

« JGO Spiffy Duke »


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #15 - Posted 2010-01-11 22:21:22 »

Xiph.org has a pure java implementation of the Theora codec available in a signed jar.  It's royalty free and is playable, but still drops frames, on my crappy laptop.


<a href="http://www.theora.org/cortado/">Cortado</a>
That looks pretty cool!

I couldn't find any example code on how to integrate it into an application instead of an Applet.

Offline GKW

Senior Devvie




Revenge is mine!


« Reply #16 - Posted 2010-01-12 00:06:37 »

If you go into the git tree there is a directory of examples including one that shows the applet embedded in a frame and manually setting the applet parameters.
Offline princec

« JGO Spiffy Duke »


Medals: 425
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #17 - Posted 2010-01-12 10:09:27 »

Hm, project seems a bit dead - no news since 2008, and no MacOS or Linux binaries for the latest version.

Cas Smiley

Offline gouessej
« Reply #18 - Posted 2010-01-14 11:55:15 »

Perhaps im searching a bit clumsy .. but where can I download the libraries for JMC?
JMC is used internally by JavaFX. Download the JavaFX SDK and look for jmc.jar (don't forget the native library for your platform, jmc.dll, jmc.so or jmc.jnilib).

Look at this to see an example of source code using JMediaPlayer:
http://floris.ouwendijk.nl/blog/index.php?blog=2&title=java_media_components&more=1&c=1&tb=1&pb=1

Offline Serethos

Junior Devvie




Java games rock!


« Reply #19 - Posted 2010-01-20 00:21:03 »

WOOOHAAA!

Now I can proudly present: A SOLUTION!

First of all thx to all the replies, the solution is indeed to extract the JMC Framework
from JavaFX.

But trying to use the tutorial in the link given by gouessej does not work:
(http://floris.ouwendijk.nl/blog/index.php?blog=2&title=java_media_components&more=1&c=1&tb=1&pb=1)
The problem is, that the posted code relates to JavaFX 1.1, but the actual Version does not support the JMediaPlayer
class anymore.

With a little search I found other, which shared the problem. Indeed you have to grab the jar-libraries and native .dlls
from the JavaFX Installation and do something like this (quick'n'dirty example, please see the original thread in this forum:
http://www.java-forum.org/allgemeine-java-themen/93807-videos-abspielen-etc.html)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
package test;

import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.io.File;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.sun.media.jmc.MediaProvider;
import com.sun.media.jmc.control.VideoRenderControl;
import com.sun.media.jmc.event.VideoRendererEvent;
import com.sun.media.jmc.event.VideoRendererListener;

public class PlayerTest implements VideoRendererListener
{

   private MediaProvider      prov;
   private VideoRenderControl   renderer;
   private Graphics2D         ig;
   private JPanel            panel;

   public PlayerTest(File path, JPanel panel)
   {
      ig = (Graphics2D) panel.getGraphics();
      this.panel = panel;
      prov = new MediaProvider(path.toURI());
      renderer = prov.getControl(VideoRenderControl.class);
      renderer.addVideoRendererListener(this);
     
      prov.play();
   }

   @Override
   public void videoFrameUpdated(VideoRendererEvent arg0)
   {
      float ratio = renderer.getFrameSize().height / (float) renderer.getFrameSize().width;

      int diff = (panel.getHeight() - Math.round(ratio * panel.getHeight())) / 2;

      renderer.paintVideo(ig, new Rectangle(0, 0, renderer.getFrameSize().width,
            renderer.getFrameSize().height), new Rectangle(0, diff, panel.getWidth(), Math.round(ratio
            * panel.getHeight())));

   }

   public static void main(String[] args)
   {
      JFrame frame = new JFrame("Video Test");
      JPanel panel = new JPanel();
      frame.getContentPane().add(panel);
      frame.setSize( new Dimension(800, 600) );
      frame.setVisible(true);
     
      File video = new File("videos/test.avi");
      new PlayerTest(video, panel);
   }
}

Offline xinaesthetic

Senior Devvie


Medals: 1



« Reply #20 - Posted 2010-01-20 01:56:15 »

Anyone got any comments on how easy it would then be to use the graphics as texture in GL?
Offline princec

« JGO Spiffy Duke »


Medals: 425
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #21 - Posted 2010-01-20 09:47:51 »

Well, very easy - just not necessarily fast enough done that way Wink

You really need a direct to OpenGL JMF renderer. I notice that that FOBs project has an OpenGL renderer in it...

Cas Smiley

Offline tom
« Reply #22 - Posted 2010-01-20 12:29:49 »

I think you'll break the JavaFX license if you extract jmc from it and provide it with your app.

Offline Serethos

Junior Devvie




Java games rock!


« Reply #23 - Posted 2010-02-02 11:33:53 »

Hmm, I am not that happy as I expected. Did anyone experiment a little around with JMC Video? There are a few problem I can not solve:

  • Even if I do not create any Window or Frame, the video is played back in a separate Frame
  • In general I am missing a reference to the video frame (e.g. to close it)

Does anybody know more?
Offline Serethos

Junior Devvie




Java games rock!


« Reply #24 - Posted 2010-03-22 13:08:50 »

So for anyone who is still interested in this issue, some kind of solution. I have discovered Xuggler:

http://www.xuggle.com/xuggler/

It is a java wrapper for FFMpeg and for the purpose of playing a video file it is way too mighty - a little
bit like firing nuclear rockets on birds. It is intended for video encoding, manipulation and encoding, but
it supports video playback for all major platforms.
My tests included playback of a 1024x768 video within Kev's Slick2D engine and it works. I need still some
improvements to get the sync between video playback and update of the engine right, but there is no
problem of getting > 25fps on faster machines.
Offline CommanderKeith
« Reply #25 - Posted 2010-03-22 13:28:38 »

Looks cool, nice find. But it's a bummer that the site uses flash for movie playback instead of a java applet + xuggler!

People in the below thread would also be interested in your discovery. Thanks for sharing it
http://www.java-gaming.org/topics/cortado-works/21933/view.html

Offline Chagma

Senior Newbie





« Reply #26 - Posted 2010-03-22 15:33:47 »

I have reservations about Xuggler namely:

  • They say themselves that video playback is experimental at best and not to be used in production.
  • They say themselves that video/audio synch doesn't work on Linux and they have no solution.
  • It has a massive footprint.  Did your tests include running it in the context of a browser?
Offline Serethos

Junior Devvie




Java games rock!


« Reply #27 - Posted 2010-03-23 14:26:39 »

Indeed you should carefully consider, whether to use Xuggler or not. Taking into account that it is quite a popular library, I guess there will be much improvement in the near future regarding performance and compatibility issues. The massive footprint is not much of a surprise and confirms my doubts that using an encoding library for the simple task of video playback is way too much.
But despite these thoughts there is still the problem to find any video playback library which works on the standard platforms at all. Like I mentioned in an early post I am still shocked how little Java advanced with video support over the past five to ten years. So it seems to me that the choice is only to get the least bad library fitting your purpose.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (73 views)
2014-11-26 15:22:04

toopeicgaming1999 (63 views)
2014-11-26 15:20:36

toopeicgaming1999 (15 views)
2014-11-26 15:20:08

SHC (29 views)
2014-11-25 12:00:59

SHC (27 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (27 views)
2014-11-24 19:59:16

trollwarrior1 (40 views)
2014-11-22 12:13:56

xFryIx (78 views)
2014-11-13 12:34:49

digdugdiggy (57 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!