Streaming media using gstreamer on the web

News Site news RSS

Latest articles New articles RSS

Latest news from Twitter Follow Secretkeeper4 and www.svesoftware.com on Twitter

Streaming media using gstreamer on the web

This article shows a simple example how to stream camera output to the web.
Software requirements: gstreamer http://gstreamer.freedesktop.org
The following command will start stream from camera to the local streaming server:

gst-launch-0.10 v4l2src ! 'video/x-raw-yuv,width=640,height=480,framerate=30/1' ! tee name=t_vid !  queue ! videorate ! video/x-raw-yuv,framerate=30/1 ! theoraenc quality=30 ! queue ! mux. pulsesrc device=alsa_input.usb-046d_081d_C2A9C4C0-00-U0x46d0x81d.analog-mono ! audio/x-raw-int,rate=48000,channels=1,depth=8 ! queue ! audioconvert ! queue ! vorbisenc ! queue ! mux. oggmux name=mux ! tcpserversink host=<host> port=<port>

Video source is v4l2src, Video4Linux. Encoder used is theoraenc with a little lowered quality.
Audio source is pulseaudio, however alsa can also be used. Option device=alsa_input.usb-046d_081d_C2A9C4C0-00-U0x46d0x81d.analog-mono is the name of pulseaudio sound device. A list of all registered pulseaudio devices can be seen using PulseAudio Manager. Replace 'device' with your input source. Replace <host> and <port> with real values.

Prepare html file with following code:

<video src="http://<host>:<port>">
    Your browser does not support the VIDEO tag and/or RTP streams.
</video>

Set properly 'src' tag to point to your tcpserversink. Allow access on firewall and don't forget to set port forwarding on router if necessary.
Open html file using chrome browser and press 'play' in the video box and video will be displayed. Approximate upstream is around 40 Kb/s.