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
location="http://admin:12345@192.168.1.100/nphMotionJpeg?Resolution=320x240&Quality=Standard&Framerate=1"
do-timestamp=true ! multipartdemux ! jpegdec ! xvimagesink

(Using capabilities = same result):
gst-launch -v gnomevfssrc
location="http://admin:12345@192.168.1.100/nphMotionJpeg?Resolution=320x240&Quality=Standard&Framerate=1"
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");
	videosrc.set("location","http://admin:12345@192.168.1.100/nphMotionJpeg?Resolution=320x240&Quality=Standard&Framerate=1");
	videosrc.set("do-timestamp",true);
	final Element filter1 = ElementFactory.make ("multipartdemux", "demuxer");
	final Element videofilter1 = ElementFactory.make("capsfilter", "filter1");
        videofilter1.setCaps(Caps.fromString("image/jpeg,width=320,height=240,framerate=1/1"));
	final Element filter2 = ElementFactory.make ("jpegdec","jpg");
	final Element videofilter2 = ElementFactory.make("capsfilter", "filter2");
        videofilter2.setCaps(Caps.fromString("video/x-raw-yuv,framerate=1/1"));

        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                VideoComponent videoComponent = new VideoComponent();
                Element videosink = videoComponent.getElement();
		pipe.addMany(videosrc, filter1, videofilter1, filter2, videofilter2,
videosink);
		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.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);
            }
        });
    }

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@192.168.1.100/nphMotionJpeg?Resolution=320x240&Quality=Standard&Framerate=1");
        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