Hi there,
after trying to play avi-files in java with VLC (unstable) and ffmpeg
(via FMJ and ffmpeg-java; not working, and / or outdated), I stumbled
across gstreamer.
As far as I can tell from the last commited source-changes, this
project is at least more active than the others (vlc for example, is
practically dead).
Anyways... I tried the VideoPlayer Tutorial from the wiki (http://
code.google.com/p/gstreamer-java/wiki/VideoPlayerTutorial) and
failed :/
First fail was, that the program couldn't locate the gstreamer-0.10-
library. I had the gstreamer package as well as base, good, bad and
ugly downloaded and so I altered my PATH in eclipse, that it would
point to the right directories. No luck. It always said, it couldn't
find the library.
Then, I tried to start the sample from command line, setting the PATH
manually. That actually worked. Yay!
But then, it failed at another point:
Exception in thread "main" java.lang.IllegalArgumentException: No such
Gstreamer factory: playbin
at org.gstreamer.ElementFactory.makeRawElement
(ElementFactory.java:172)
at org.gstreamer.Element.makeRawElement(Element.java:94)
at org.gstreamer.elements.PlayBin.<init>(PlayBin.java:244)
at VideoPlayer.main(VideoPlayer.java:19)
I now have no clue what to do.
Appearently, there are two problems:
1. JNA can't locate the libraries when started from eclipse (though
PATH is set)
2. There is a problem with the PlayBin-Factory.
I guess, the first problem doesn't concern you guys, and neither
concerns me, as long, as I get this thing running, but problem number
two should be of interest for you :)
Maybe someone could help me out, thank you.
Just in case, I'm posting the source of the VideoPlayer.java-sample
here:
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import org.gstreamer.Gst;
import org.gstreamer.State;
import org.gstreamer.elements.PlayBin;
import org.gstreamer.swing.VideoComponent;
public class VideoPlayer {
public static void main(String[] args) {
args = Gst.init("VideoPlayer", args);
final PlayBin playbin = new PlayBin("VideoPlayer");
playbin.setInputFile(new File(args[0]));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
VideoComponent videoComponent = new VideoComponent();
playbin.setVideoSink(videoComponent.getElement());
JFrame frame = new JFrame("VideoPlayer");
frame.getContentPane().add(videoComponent,
BorderLayout.CENTER);
frame.setPreferredSize(new Dimension(640, 480));
frame.setDefaultCloseOperation
(WindowConstants.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
playbin.setState(State.PLAYING);
}
});
Gst.main();
playbin.setState(State.NULL);
}
}