How to display video streamed from UDP source?

Jim Norton jimnorton at jimnorton.org
Tue May 7 13:42:40 PDT 2013


I have a small program that uses the GStreamer library to play videos  
from local files and videos on webservers using HTTP.

How does one go about connecting to and playing a UDP video broadcast  
in C using GStreamer?


For example, what is required to play the streaming video at this  
hypothetical URI? 10.0.11.255:9001

I have to be able to play a streaming video that is created using the  
following sample VLC command:

cvlc -vvv /vlc/attract.mpg :norm=ntsc :v4l2-width=320 :v4l2-height=240  
:v4l2-standard=45056 :channel=1 --no-sout-audio --sout  
'#transcode{vb="1600",vcodec=mpgv,acodec=mpga,venc=ffmpeg}:standard{access=udp,mux=ts,dst=10.0.11.255:9001}' --loop --ttl  
1


I tried:

// using playbin2 connect to UDP broadcast
g_object_set (data.playbin2, "uri", "udp://10.0.11.255:9001", NULL);

Then I try to start the stream with the following:

/* Start playing */
     if( gst_element_set_state (data.playbin2, GST_STATE_PLAYING) ==  
GST_STATE_CHANGE_FAILURE )
     {
         g_printerr ("Unable to set the pipeline to the playing state.\n");
         gst_object_unref (data.playbin2);
         return( -1 );
     }

and I get the failure to change state message.

After some more googling, I found out about udpsrc. However, I can't  
figure out how to use it in C code. I've gone through the tutorials,  
but have not found any examples showing how to play a video streaming  
via VLC from a UDP port.

Any and all help would be greatly appreciated.



More information about the gstreamer-devel mailing list