Saturday, October 19, 2013

Raspberry Pi - Gstreamer streaming H.264 with OpenMax

On Rasbian:
* add the following line to /etc/apt/sources.list
deb http://vontaene.de/raspbian-updates/ . main
* install:
apt-get update
apt-get install libgstreamer1.0-0-dbg gstreamer1.0-tools libgstreamer-plugins-base1.0-0 \
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad-dbg gstreamer1.0-omx gstreamer1.0-alsa



Raspberry pi's pipeline:
gst-launch-1.0 -v videotestsrc ! 'video/x-raw, width=640, height=480, framerate=15/1' ! queue ! videoconvert ! omxh264enc ! rtph264pay pt=96 ! udpsink host=REMOTE_IP port=500




Linux's pipeline:
sudo gst-launch-0.10 udpsrc port=500 ! 'application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" ! gstrtpjitterbuffer mode=slave latency=200 drop-on-latency=true ! rtph264depay ! video/x-h264,width=640,height=480, framerate=30/1 ! ffdec_h264 ! ffmpegcolorspace ! xvimagesink


16 comments:

Pablo Arthur said...

Emmanuel:
It is incredible what you can do with the raspberry pi. I just got mine today! I already saw your project with the radio TEA5767. I do have a similar project but I want to get the audio back to the raspberry pi with a codec to be able to save the PCM or WAV from the FM radio? Is that too hard? There is no audio input on the pi, but I read you can do it through the I2C from the P5? Is that possible?
Thanks you very much! Amazing!!!

Matt lokes said...

Hi, Nice work!! This is exactly what i was looking to do. However I think there maybe a few copy and paste mistakes in your code. I think your code should be this instead:

Raspberry pi's pipeline:

gst-launch-1.0 -v v4l2src ! 'video/x-raw, width=640, height=480, framerate=15/1' ! queue ! videoconvert ! omxh264enc ! rtph264pay pt=96 ! udpsink host=REMOTE_IP port=500

Linux Reciever Pipeline:

gst-launch udpsrc port=5000 ! "application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264,payload=(int)96" ! gstrtpjitterbuffer mode=slave latency=200 drop-on-latency=true ! rtph264depay ! video/x-h264,width=640,height=480, framerate=30/1 ! ffdec_h264 ! ffmpegcolorspace ! xvimagesink

I learnt quite a lot working out why the pipeline didn't work though, so it was a good learning experience. :D

Matt

Matt lokes said...
This comment has been removed by the author.
Matt lokes said...

Oooops the udpsrc port should be 500 not 5000 ! My bad!

Emmanuel Granatello said...

:) now it work?

Matt lokes said...

With the changes in my first post it works great :) Thanks! My correction in my second post referred to a mistake in my code i posted.

Emmanuel Granatello said...

I've updated the post, tnks! ;)

Nguyen Thuan said...

How about Raspi & Client are behind NAT in the different network!

Amr M.Elsaid said...

When I try to install the packages :
apt-get install libgstreamer1.0-0-dbg gstreamer1.0-tools libgstreamer-plugins-base1.0-0 \
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad-dbg gstreamer1.0-omx gstreamer1.0-alsa

I got that error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libgstreamer1.0-0-dbg
E: Couldn't find any package by regex 'libgstreamer1.0-0-dbg'
E: Unable to locate package gstreamer1.0-tools
E: Couldn't find any package by regex 'gstreamer1.0-tools'
E: Unable to locate package libgstreamer-plugins-base1.0-0
E: Couldn't find any package by regex 'libgstreamer-plugins-base1.0-0'
E: Unable to locate package gstreamer1.0-plugins-good
E: Couldn't find any package by regex 'gstreamer1.0-plugins-good'
E: Unable to locate package gstreamer1.0-plugins-bad-dbg
E: Couldn't find any package by regex 'gstreamer1.0-plugins-bad-dbg'
E: Unable to locate package gstreamer1.0-omx
E: Couldn't find any package by regex 'gstreamer1.0-omx'
E: Unable to locate package gstreamer1.0-alsa
E: Couldn't find any package by regex 'gstreamer1.0-alsa'

Could anyone help me fix it,please ?

Shyam said...

Run it as sudo apt-get install

Shyam said...

Buddy what is this pipeline stuff? Is there anyway i can make raspberry run it automatically at startup?

Unknown said...

this looks good but is there a way to do this without the conversion? I have a usb cam that can output h264 and I want to make use of that rather convert raw to h264?

Phạm Thành Nam said...

Correction for me:
sudo gst-launch udpsrc port=500 ! "application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264,payload=(int)96" ! gstrtpjitterbuffer mode=slave latency=200 drop-on-latency=true ! rtph264depay ! video/x-h264,width=640,height=480, framerate=30/1 ! ffdec_h264 ! ffmpegcolorspace ! xvimagesink
It is weird that I need to launch Raspberry Pi pipeline AFTER Linux pipeline, or kill Raspberry Pi pipeline and relaunch it. If I launch it BEFORE Linux pipeline, nothing is shown.

gleb22 said...

I have the same problem, and sudo doesn't solve it

Anonymous said...

Hi, Neat post. TҺere is an issuе together with your website
in web explorer, would check this? IE still is the market chieff and a good component of otheг people
will miss your great writіng duee to tҺis pгoblem.


Feel free to visit my page strawberry-banana crepe recipe

Anonymous said...

can I download an image file?