gstreamer allows you to stream video with very low latency – a problem with VLC currently.  The catch is that you need need gstreamer on the client used to view the stream.  gstreamer is a development framework not a media player and there isn't a way to stream so that common players such as VLC can display the stream (without users having to install complex plugins).  So, gstreamer can provide an excellent low latency video link, which is great if you are techy enough to set it up at both ends, but its no good if you want to directly stream so that Joe public can see the video on a web site for instance.

Setting Up The Raspberry Pi To Use gstreamer

You need to edit the sources.list file so enter:


sudo nano /etc/apt/sources.list

and add the following to the end of the file:


deb http://vontaene.de/raspbian-updates/ . main

Press CTRL+X to save and exit

Now run an update (which will make use of the line just added):


sudo apt-get update 

Now install gstreamer


sudo apt-get install gstreamer1.0

To Stream The Video From the Raspberry Pi

Enter this on the command lne:


raspivid -t 0 -h 720 -w 1080 -fps 25 -hf -b 2000000 -o - | gst-launch-1.0 -v fdsrc ! h264parse !  rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=YOUR_RPI_IP_ADDRESS port=5000

Change YOUR_RPI_IP_ADDRESS to be the IP address of your  RPI.

To View The Stream

There's a lot of resources around for this.  Seems to be pretty easy on Linux, OK on a MAC and harder on Windows. Apparently streaming from RPi to PRi works really well.

 





USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.

Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

  • Dulle

    it seems that gstreamer1.0 isnt working with newest wheezy

  • victor

    I got this on server side:

    raspivid -t 0 -h 720 -w 1080 -fps 25 -hf -b 2000000 -o – | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=192.168.0.95 port=8000

    Setting pipeline to PAUSED …

    /GstPipeline:pipeline0/GstTCPServerSink:tcpserversink0: current-port = 8000

    Pipeline is PREROLLING …

    /GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:src: caps = video/x-h264, width=(int)1080, height=(int)720, parsed=(boolean)true, stream-format=(string)avc, alignment=(string)au, codec_data=(buffer)01640028ffe1000f27640028ac2b402202df2f00f1226a01000528ee025cb0

    /GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0.GstPad:src: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, sprop-parameter-sets=(string)”J2QAKKwrQCIC3y8A8SJq,KO4CXLA=”, payload=(int)96, ssrc=(uint)1881178431, timestamp-offset=(uint)3771518638, seqnum-offset=(uint)44220

    /GstPipeline:pipeline0/GstGDPPay:gdppay0.GstPad:sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, sprop-parameter-sets=(string)”J2QAKKwrQCIC3y8A8SJq,KO4CXLA=”, payload=(int)96, ssrc=(uint)1881178431, timestamp-offset=(uint)3771518638, seqnum-offset=(uint)44220

    /GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0.GstPad:sink: caps = video/x-h264, width=(int)1080, height=(int)720, parsed=(boolean)true, stream-format=(string)avc, alignment=(string)au, codec_data=(buffer)01640028ffe1000f27640028ac2b402202df2f00f1226a01000528ee025cb0

    /GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0: timestamp = 3771518638

    /GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0: seqnum = 44220

    /GstPipeline:pipeline0/GstGDPPay:gdppay0.GstPad:src: caps = application/x-gdp, streamheader=(buffer)

    /GstPipeline:pipeline0/GstTCPServerSink:tcpserversink0.GstPad:sink: caps = application/x-gdp, streamheader=(buffer)

    Pipeline is PREROLLED …

    Setting pipeline to PLAYING …

    New clock: GstSystemClock

    but I have no idea how to connect to server to view the stream.
    I tried MXPlayer and safari (which redirect to quicktime). rtsp://192.168.0.95:8000 was used as link

    Please help me.

  • realbanda

    install gstreamer-tools package

    apt-get install gstreamer-tools

  • thomas

    i type this..

    raspivid -t 0 -h 720 -w 1080 -fps 25 -hf -b 2000000 -o – | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=192.168.2.118 port=5000

    and this happens

    -bash: gst-launch-1.0: command not found

    HELP!!!!!

  • David Kapolka

    viewing the stream–don’t cross the streams–Ghostbusters circa 1984 perhaps before your time. Have not been able to get windows, ubuntu, or raspberry pi to decode gstreamer encoded video streams from my pie.

  • John Sweeney

    Hi, I have been trying to use raspberry pi 2 to transcode videos that I record using mythtv on another machine. After a lot of trial and error I think I have finally got a successful setup. The important things I needed were:
    1. at least a 3amp power source
    2. gpu memory at least 256MB to prevent gst via the OMX plugin from failing for lack of memory
    3. edit /etc/sysctl.conf:
    # rpi tweaks
    vm.swappiness=10
    vm.min_free_kbytes = 16384
    to ensure no failure for lack of RAM
    4. in gst-launch-1.0 use: queue max-size-bytes=0 max-size-buffers=0 max-size-time=5000000000
    to prevent the gst pipeline from stalling for lack of synchronized data
    5. also: queue ! videoconvert ! videoscale ! video/x-raw,width=1920,height=1080 ! omxh264enc control-rate=1 target-bitrate=15000000 ! video/x-h264,profile=high ! h264parse
    I want high quality video, in matroska container to be able to stream using my dlna server to my TV
    6. there are is a bunch of other things I do with the mythtv source file to preserve subtitles and remove commercials but that’s not for here.

  • Thanks for sharing John

  • John Sweeney

    My pleasure. I have a further suggestion. I have had quite a bit of trouble with memory, between gpu and arm. So I am now trying this http://www.raspberrypi.org/phpBB3/viewtopic.php?p=223549#p223549
    a dynamic split between them and so far it seems to be much much better.

  • Brad

    Hey John. What version of raspbian are you using? I installed the newest version and an apt-get update and installed gstreamer1.0. However, I am just getting a still picture. I have tested the raspvid locally on the pi and the video works fine. However, when I stream through gstreamer and launch gstreamer from windows, I just get a single still frame.

    Settings
    Rapberry pi b model
    raspi-config memory split 128/256 (tried both)
    gstreamer1.0 installed
    raspi-config (enabled cam)
    Ethernet/wifi attempts
    Power 700ma supply/ (Have 2 amp on the way)

    RPI Commands
    raspivid -t 0 -w 1280 -h 720 -fps 30 -b 1700000 -o – | gst-launch-1.0 -v fdsrc ! h264parse config-interval=1 ! rtph264pay ! udpsink host = [Win7 IP] port= 9000

    Win7 Gstreamer commands
    gst-launch-1.0 udpsrc port=9000 ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink

    What issues did you run into with a power supply less than 3 amps? Hopefully, you had the same issue with a single still frame and no stream? Your comment inspired me to get a bigger power supply. I am just looking for your input at failed attempt and what the resolution was.

    Thanks for any input!

  • John Sweeney

    Sorry for not replying earlier. I have latest raspbian and gstreamer1.0 from the raspbian repository, 1.2. I have had some issues with varieties of rpi-update of firmware, but those guys have fixed them quickly.
    Mine is a raspberry pi b, too.
    The power supply issue: when the the cpu was fairly heavily engaged transcoding, the pi turned off or froze completely. Improving the current available fixed that. And I wasn’t powering anything else, no usb, no mouse, no keyboard, only the nic.
    I have only been using it to transcode videos, no still frames.
    I had no luck with the config-interval switch on h264parse, I stopped using it all together.
    As I say, I am now using the dynamic memory split. Seems better to me.

  • Brad

    Thanks. The initial problem was exactly that…config-interval=1. Once I removed this from the command, the video finally worked.

  • ncx94

    Hi,

    just tryed to install gstreamer using your methid but it wouldn’t work.. any idea if anything has changed?

    i’m using the latest raspbian

    Thanks,

    nick

  • Trevor

    John, thanks to you I have managed to stream my tvheadend recordings to rtmp successfully.

    This is my pipeline:
    gst-launch-1.0 filesrc location=video.ts ! decodebin name=demux demux. ! queue leaky=1 max-size-bytes=0 max-size-buffers=0 max-size-time=25000000000 ! audioresample ! audioconvert dithering=0 ! voaacenc ! mux. flvmux name=mux streamable=true ! rtmpsink location=rtmp://localhost/recordings/test demux. ! queue leaky=1 max-size-bytes=0 max-size-buffers=0 max-size-time=25000000000 ! videoconvert ! videoscale ! video/x-raw,width=1920,height=1080 ! omxh264enc control-rate=1 target-bitrate=2000000 ! video/x-h264,profile=high ! h264parse ! mux.

    Audio and video works perfect, but if there is more that one audio track I always get the first one. Also it looks like I get the first subtitle track as well, but no subtitles shows up in VLC.
    Do you know how to chose the correct audio track, and how to mux the correct subtitle track?

  • John Sweeney

    Hi Trevor. I’m afraid I don’t off hand. But I did see some conversations about that a long time ago. I will have a look for you. Subtitles are tricky. What codec does your original use for them? For mine, they are teletext subtitles and gst does not have a decoder for them. The teletext protocol uses pages to identify the appropriate text and can be very variable according to the transmitter. So I have to use a subtitle extractor that comes with myth TV. And then recombine them using mkvmerge. It is a long and cumbersome process but it does work.

  • John Sweeney

    Perhaps if you have a bit more detail about what you did and what happened?

  • Trevor

    John,

    Thanks for a quick response and thanks for helping.
    My goal is to get the english audio track and the finnish subtitle track.

    This is the output from gst-discoverer-1.0:

    Topology:

    container: video/mpegts, systemstream=(boolean)true, packetsize=(int)188

    subtitles: subpicture/x-dvb

    Codec:

    subpicture/x-dvb

    Additional info:

    None

    Stream ID: fc8efabdfd3f4e290b84b740b255880c0de5b979597e09ead0c3b1cdef52c6a 3/00001989

    Language: fi

    Tags:

    taglist, language-code=(string)fi, subtitle-codec=(string)”DVB subtitle s”;

    audio: audio/x-ac3

    Codec:

    audio/x-ac3

    Additional info:

    None

    Stream ID: fc8efabdfd3f4e290b84b740b255880c0de5b979597e09ead0c3b1cdef52c6a 3/0000106d

    Language: cs

    Channels: 6

    Sample rate: 48000

    Depth: 32

    Bitrate: 384000

    Max bitrate: 384000

    Tags:

    taglist, language-code=(string)cs, audio-codec=(string)”AC-3 (ATSC A/ 52)”, minimum-bitrate=(uint)384000, bitrate=(uint)384000, maximum-bitrate=(uint )384000;

    audio: audio/x-ac3

    Codec:

    audio/x-ac3

    Additional info:

    None

    Stream ID: fc8efabdfd3f4e290b84b740b255880c0de5b979597e09ead0c3b1cdef52c6a 3/0000106e

    Language: hu

    Channels: 6

    Sample rate: 48000

    Depth: 32

    Bitrate: 384000

    Max bitrate: 384000

    Tags:

    taglist, language-code=(string)hu, audio-codec=(string)”AC-3 (ATSC A/ 52)”, minimum-bitrate=(uint)384000, bitrate=(uint)384000, maximum-bitrate=(uint )384000;

    audio: audio/x-ac3

    Codec:

    audio/x-ac3

    Additional info:

    None

    Stream ID: fc8efabdfd3f4e290b84b740b255880c0de5b979597e09ead0c3b1cdef52c6a 3/00001031

    Language: en

    Channels: 6

    Sample rate: 48000

    Depth: 32

    Bitrate: 384000

    Max bitrate: 384000

    Tags:

    taglist, language-code=(string)en, audio-codec=(string)”AC-3 (ATSC A/ 52)”, minimum-bitrate=(uint)384000, bitrate=(uint)384000, maximum-bitrate=(uint )384000;

    video: video/x-h264, stream-format=(string)byte-stream, alignment=(string)na l

    Codec:

    video/x-h264, stream-format=(string)byte-stream, alignment=(string)nal

    Additional info:

    None

    Stream ID: fc8efabdfd3f4e290b84b740b255880c0de5b979597e09ead0c3b1cdef52c6a 3/00000421

    Width: 1920

    Height: 1080

    Depth: 0

    Frame rate: 25/1

    Pixel aspect ratio: 1/1

    Interlaced: true

    Bitrate: 0

    Max bitrate: 0

    Tags:

    taglist, video-codec=(string)H.264;

    Properties:

    Duration: 0:02:00.444929888

    Seekable: yes

    Tags:

    language code: hu

    audio codec: AC-3 (ATSC A/52)

    minimum bitrate: 384000

    bitrate: 384000

    maximum bitrate: 384000

    subtitle codec: DVB subtitles

    video codec: H.264

  • John Sweeney

    as for the selection of audio track, this might help: https://blogs.gnome.org/uraeus/2012/11/25/improved-handling-of-files-with-multiple-tracks-in-gstreamer/
    where the subtitles are concerned, there is a dvbsuboverlay in gst 1.7 which isn’t on raspberry… so… maybe soonish…

  • Trevor

    I finally managed to get the right audio track. In my pipeline I have to use tsdemux name=demux instead of decodebin name=demux

    Then for the audio i use demux.audio_1031, where 1031 is the last four numbers in the stream ID from gst-discoverer.

    Subtitle tracks are chosen the same way. I have tried to implement the information found in these links:

    http://designsomething.org/leopardboard/f/23/t/738.aspx

    https://developer.gnome.org/gst-plugins-libs/stable/gst-plugins-base-plugins-subtitleoverlay.html

    http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-subtitleoverlay.html

    http://gstreamer-devel.966125.n4.nabble.com/DVB-sub-pictures-wrongly-displayed-td4172790.html

    https://github.com/ford-prefect/gst-plugins-bad/blob/master/gst/dvbsuboverlay/gstdvbsuboverlay.c

    But I don’t have enough knowledge about how gst-launch works to implement it into my project.

    This is as far as I have come, but I don’t know where to put this “r.” to make the subtitles overlay the video:

    gst-launch-1.0 filesrc location=video.ts ! tsdemux name=demux demux.audio_1031 ! queue leaky=1 max-size-bytes=0 max-size-buffers=0 max-size-time=25000000000 ! ac3parse ! a52dec ! audioresample ! audioconvert ! “audio/x-raw,channels=2” ! voaacenc ! mux. flvmux name=mux streamable=true ! rtmpsink location=rtmp://localhost/recordings/test demux. ! queue leaky=1 max-size-bytes=0 max-size-buffers=0 max-size-time=25000000000 ! h264parse ! omxh264dec ! videoconvert ! videoscale ! video/x-raw,width=1920,height=1080 ! omxh264enc control-rate=1 target-bitrate=2000000 ! video/x-h264,profile=high ! h264parse ! mux. demux.subpicture_1989 ! queue leaky=1 max-size-bytes=0 max-size-buffers=0 max-size-time=25000000000 ! “subpicture/x-dvb” ! dvbsuboverlay name=r

    Do you have any ideas?

  • christoph

    hello same trouble with jessie:

    sudo apt-get install gstreamer1.0

    Lecture des listes de paquets… Fait

    Construction de l’arbre des dépendances

    Lecture des informations d’état… Fait

    Note, selecting ‘gstreamer1.0-fluendo-mp3’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-vaapi’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-audiosource’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-vaapi-doc’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-clutter’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-alsa’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-videosink’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-visualization’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-omx’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-base-apps’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-tools’ for regex ‘gstreamer1.0’

    Note, selecting ‘libgstreamer1.0-0-dbg’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-pulseaudio’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-omx-dbg’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-ugly-doc’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-base-doc’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-really-bad’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-ugly’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-doc’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-libav-dbg’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-good’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-ffmpeg’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-good-dbg’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-bad-dbg’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-gnonlin-dbg’ for regex ‘gstreamer1.0’

    Note, selecting ‘libgstreamer1.0-dev’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-audiosink’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-videosource’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-gnonlin’ for regex ‘gstreamer1.0’

    Note, selecting ‘libgstreamer1.0-0’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-good-doc’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-bad-doc’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-gnonlin-doc’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-base’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-packagekit’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-nice’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-lame’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-x’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-libav’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-ugly-dbg’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-gnomevfs’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-base-dbg’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-bad’ for regex ‘gstreamer1.0’

    Note, selecting ‘gstreamer1.0-plugins-good’ instead of ‘gstreamer1.0-visualization’

    gstreamer1.0-alsa est déjà la plus récente version disponible.

    gstreamer1.0-libav est déjà la plus récente version disponible.

    gstreamer1.0-plugins-base est déjà la plus récente version disponible.

    gstreamer1.0-plugins-good est déjà la plus récente version disponible.

    gstreamer1.0-x est déjà la plus récente version disponible.

    libgstreamer1.0-0 est déjà la plus récente version disponible.

    libgstreamer1.0-0 passé en « installé manuellement ».

    gstreamer1.0-plugins-bad est déjà la plus récente version disponible.

    Certains paquets ne peuvent être installés. Ceci peut signifier

    que vous avez demandé l’impossible, ou bien, si vous utilisez

    la distribution unstable, que certains paquets n’ont pas encore

    été créés ou ne sont pas sortis d’Incoming.

    L’information suivante devrait vous aider à résoudre la situation :

    Les paquets suivants contiennent des dépendances non satisfaites :

    gstreamer1.0-omx-dbg : Dépend: gstreamer1.0-omx (= 1.0.0.1-0+rpi18rpi1g) mais 1.2.0-1 devra être installé

    E: Impossible de corriger les problèmes, des paquets défectueux sont en mode « garder en l’état ».

  • ncx94

    Hi,

    Thanks or your help!
    So i’ve installed the latest gstreamer version from raspbian standard sources. When i launch the command for gstreamer i get every thing to look fine (it displays the video image on the screen connected to the pi, ssh shows “Setting pipeline to PLAYING” and Newclock: GetSystemClock but i can’t get the computer to display the feed…

  • ncx94

    Pour éviter ce problème, il ne faut plus utiliser la source indiqué ci dessus mais simplement faire un sudo apt-get install gstreamer1.0 gstreamer1.0-tools parce que les paquets sont déjà dispo dans raspbian et les installer depuis une autre source crée des problèmes de compatibilité :)
    reset le pi et installes direct :)

  • Foufoutos

    Hello. How is it in terms of difficulty to stream this on Android? Any help would be much appreciated.

  • Trevor

    I’m still not getting transcoding with rpi 2 and gstreamer to work 100%
    My problem is that the ram is filling up. Right now I have two queues, one for audio and one for video.

    I have set ‘no limit’ for how large the queues can be. When transcoding, everything goes fine until the ram is filed up and the pi crashes (takes about 25 minutes for 720p h264 video.) When I try the max-size-time=5000000000 setting for the queue the output file will look good for 5 seconds, then frames are lost every 5 seconds. I have also tried the leaky=1 and leaky=2 settings for the queue, but no luck.

    Why doesn’t the data that have already been processed by the encoders/decoders get released from the ram? There is no point storing everything in the queue until gst-launch-1.0 has shuts down.

    I hope someone can explain these things to me.

    Thanks!

  • matthew wells

    When i run sudo apt-get update i get

    W: GPG error: http://vontaene.de . Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY F0DAA5410C667A3E

    and according to

    http://vontaene.de/apt/README.txt

    i should be able to fix with

    gpg –recv-key 0C667A3E
    gpg -armor –export 0C667A3E | apt-key add –

    but this does not work any ideas

  • Euan Ramsay

    I actually can’t get my VLC (on a mac) to pick this up. I’ve tried all the rtp, udp settings etc, and no joy. It just immediately errors out. Server is running fine.

  • arjamizo

    `sudo apt-key adv –recv-keys –keyserver keyserver.ubuntu.com F0DAA5410C667A3E`