What's wrong with this code?

Alberto Lepe dev at alepe.com
Thu Jan 26 20:20:16 PST 2012

Hello, these commands display the video from a network camera without problems:

gst-launch -v gnomevfssrc
do-timestamp=true ! multipartdemux ! jpegdec ! xvimagesink

(Using capabilities = same result):
gst-launch -v gnomevfssrc
do-timestamp=true ! multipartdemux !
image/jpeg,width=320,height=240,framerate=1/1 ! jpegdec !
video/x-raw-yuv,framerate=1/1 ! xvimagesink

I'm trying to implement the above in Java and in Vala (for a benchmark):

Java Code:

    public static void main(String[] args) {
        args = Gst.init("VideoTest", args);
        final Pipeline pipe = new Pipeline("VideoTest");
	final Element videosrc = ElementFactory.make ("gnomevfssrc", "video");
	final Element filter1 = ElementFactory.make ("multipartdemux", "demuxer");
	final Element videofilter1 = ElementFactory.make("capsfilter", "filter1");
	final Element filter2 = ElementFactory.make ("jpegdec","jpg");
	final Element videofilter2 = ElementFactory.make("capsfilter", "filter2");

        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                VideoComponent videoComponent = new VideoComponent();
                Element videosink = videoComponent.getElement();
		pipe.addMany(videosrc, filter1, videofilter1, filter2, videofilter2,
		Element.linkMany(videosrc, filter1, videofilter1, filter2,
videofilter2, videosink);

                // Now create a JFrame to display the video output
                JFrame frame = new JFrame("Swing Video Test");
                frame.add(videoComponent, BorderLayout.CENTER);
                videoComponent.setPreferredSize(new Dimension(720, 576));

                // Start the pipeline processing

It opens a window and displays a black background (nothing else). I
have tried without using the Caps but the result is the same.
No errors are displayed.

Vala Code:

    private void setup_gst_pipeline () {
        var pipeline = new Pipeline ("mypipeline");
        var src = ElementFactory.make ("gnomevfssrc", "video");
        var src.set_property("location","http://admin:12345@");
        var src.set_property("do-timestamp",1);
        var filter1 = ElementFactory.make ("multipartdemux","demuxer");
        var filter2 = ElementFactory.make ("jpegdec","jpg");
//        var filter2.set_property("caps",Caps.from_string("image/jpeg,width=320,height=240,framerate=1/1"));
        var sink = ElementFactory.make ("xvimagesink", "sink");
//        var sink.set_property("caps",Caps.from_string("video/x-raw-yuv,framerate=1/1"));
        pipeline.add_many (src, filter1, filter2, sink);
        src.link (filter1);
        filter1.link (filter2);
        filter2.link (sink);

I'm not setting any Caps in Vala as I still don't know which is the
proper way to do it.
It does nothing. No error no image (not even a black background as in Java).

I'm sure I'm missing something here. (sorry I'm noob in Gst).

Thank you in advance!

More information about the gstreamer-devel mailing list