What's wrong with this code?

Nathanael D. Noblet nathanael at gnat.ca
Thu Jan 26 20:28:29 PST 2012


On 01/26/2012 09:20 PM, Alberto Lepe wrote:
> 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);

You can't link a demuxer directly to a pipeline. Demuxers don't know 
what pads will exist until it sees data. You need to look at dealing 
with the 'pad-added' signal.

The gstreamer 'hello world' app shows you how to do this in C, I've got 
no idea about java or vala...

-- 
Nathanael d. Noblet
t 403.875.4613


More information about the gstreamer-devel mailing list