I'm trying to run the Gstreamer Java tutorials (https://code.google.com/p/gstreamer-java/wiki/Tutorials). But I run into a "No such Gstreamer factory" error now.
From a hunt around the internet it seems to be something to do with the computer architecture (32 or 64 bit) but I can't see how to resolve the problem.
I'm running OSX 10.8.5 (64 bit), Java 1.7.
Any ideas?
Thanks! Ed
EDIT:
java -version
java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
And the code to run is:
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.*;
import org.gstreamer.*;
import org.gstreamer.swing.VideoComponent;
public class VideoTest {
public VideoTest() {
}
private static Pipeline pipe;
private static String libDir;
private static final Object[][] DEPENDENCIES = {
// glib libraries
{"gio-2.0", new String[]{}, true},
{"glib-2.0", new String[]{}, true},
{"gmodule-2.0", new String[]{}, true},
{"gobject-2.0", new String[]{}, true},
{"gthread-2.0", new String[]{}, true},
// Core gstreamer libraries
{"gstapp-0.10", new String[]{}, true},
{"gstaudio-0.10", new String[]{}, true},
{"gstbase-0.10", new String[]{}, true},
{"gstbasevideo-0.10", new String[]{}, true},
//{"gstcdda-0.10", new String[]{}, true},
{"gstcontroller-0.10", new String[]{}, true},
{"gstdataprotocol-0.10", new String[]{}, true},
{"gstfft-0.10", new String[]{}, true},
{"gstinterfaces-0.10", new String[]{}, true},
//{"gstnet-0.10", new String[]{}, true},
{"gstnetbuffer-0.10", new String[]{}, true},
{"gstpbutils-0.10", new String[]{}, true},
{"gstphotography-0.10", new String[]{}, true},
{"gstreamer-0.10", new String[]{}, true},
{"gstriff-0.10", new String[]{}, true},
{"gstrtp-0.10", new String[]{}, true},
{"gstrtsp-0.10", new String[]{}, true},
{"gstsdp-0.10", new String[]{}, true},
//{"gstsignalprocessor-0.10", new String[]{}, true},
{"gsttag-0.10", new String[]{}, true},
{"gstvideo-0.10", new String[]{}, true},};
public static void main(String[] args) {
libDir = System.getProperty("user.dir");
//MAC64
if (System.getProperty("os.name").contains("OS")) {
if (System.getProperty("sun.arch.data.model").contains("64")) {
libDir = libDir + "/MAC64";
}
}
//PC64
if (System.getProperty("os.name").contains("Win")) {
if (System.getProperty("sun.arch.data.model").contains("64")) {
libDir = libDir + "\\PC64";
}
}
//PC32
if (System.getProperty("os.name").contains("Win")) {
if (System.getProperty("sun.arch.data.model").contains("32")) {
libDir = libDir + "\\PC32";
}
}
for (Object[] a : DEPENDENCIES) {
try {
NativeLibrary.addSearchPath(a[0].toString(), libDir);
Native.loadLibrary(a[0].toString(), DummyLibrary.class);
} catch (UnsatisfiedLinkError ex) {
System.out.println("Error loading: " + a[0].toString());
}
}
Gst.setUseDefaultContext(false);
args = Gst.init("VideoTest", args);
pipe = new Pipeline("VideoTest");
final Element videosrc = ElementFactory.make("videotestsrc", "source");
final Element videofilter = ElementFactory.make("capsfilter", "filter");
videofilter.setCaps(Caps.fromString("video/x-raw-yuv, width=720, height=576"
+ ", bpp=32, depth=32, framerate=25/1"));
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
VideoComponent videoComponent = new VideoComponent();
Element videosink = videoComponent.getElement();
pipe.addMany(videosrc, videofilter, videosink);
Element.linkMany(videosrc, videofilter, videosink);
// Now create a JFrame to display the video output
JFrame frame = new JFrame("Swing Video Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(videoComponent, BorderLayout.CENTER);
videoComponent.setPreferredSize(new Dimension(720, 576));
frame.pack();
frame.setVisible(true);
// Start the pipeline processing
pipe.setState(State.PLAYING);
}
});
}
public interface DummyLibrary extends Library {
}
}
Where the directories hold the lib/dylib files. This is based on code from Praxis LIVE (https://code.google.com/p/praxis/).
From their website :
The GStreamer team is pleased to announce binary builds for GStreamer 1.0.7, the plugin modules and all their dependencies ... Builds are currently provided for Windows (32/64 bit), Mac OS X (32/64 bit x86) and Android (ARM). Future releases will include support for iOS. 2013-06-10
You aren't facing a compatibility problem, but this error No such Gstreamer factory
should be a missing package of GStreamer containing the factory you try to use.
Check your installation by running gst-launch videotestsrc ! autovideosink
and look for any issue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With