titusece
Posts: 69
Joined: Sat Sep 10, 2016 3:24 pm
Location: India

Raspberry pi camera streaming

Sat May 12, 2018 2:38 pm

Hello Experts,
Can you please share me the gstreamer commands to stream from rpi3 camera to another rpi3 board ?
I am using the latest new raspian stretch image.
Can you please help on this ?
It needs to be done through only gstreamer commands as I need to use gstreamer in another applications.

titusece
Posts: 69
Joined: Sat Sep 10, 2016 3:24 pm
Location: India

Re: Raspberry pi camera streaming

Mon May 14, 2018 1:43 pm

Any help please.

ElEscalador
Posts: 950
Joined: Tue Dec 15, 2015 4:55 pm
Location: Detroit, MI USA

Re: Raspberry pi camera streaming

Mon May 14, 2018 2:08 pm

I am not familiar with gstreamer, but if you have streaming or camera preview up and running on the local/hosting rpi, I have used realVNC to remotely view the screen. It used to be a beta option you had to enable to be able to watch streaming video preview stuff. Not sure if it's still beta or just a regular feature now.
Robotics tips, hacks, book extras https://youtube.com/practicalrobotics

titusece
Posts: 69
Joined: Sat Sep 10, 2016 3:24 pm
Location: India

Re: Raspberry pi camera streaming

Mon May 14, 2018 2:28 pm

Thanks for the reply.
I have to initiate the gstreamer in one rpi board and want to stream the camera to another rpi board. (this raspberry pi board also should receive by gstreamer command)

Place 1 -> RPI3_1 (with camera -> 192.168.0.50)
raspivid -n -t 0 -rot 180 -w 640 -h 480 -fps 30 -b 1000000 -o - | gst-launch-1.0 -e -vvvv fdsrc ! h264parse ! rtph264pay pt=96 config-interval=5 ! udpsink host=192.168.0.53 port=5000

Place 2 -> RPI3_2 (without camera -> 192.168.0.53)
Here I need gstreamer commands to receive the camera streaming.

I need to test with the latest raspian image.

titusece
Posts: 69
Joined: Sat Sep 10, 2016 3:24 pm
Location: India

Re: Raspberry pi camera streaming

Tue May 15, 2018 12:48 pm

Any help from raspberry pi team or community members please ?
I think, it should be straight forward, I did google, not able to get the commands.

User avatar
HermannSW
Posts: 5178
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Raspberry pi camera streaming

Tue May 15, 2018 1:10 pm

I use these gstreamer pipelines when the Raspberry with camera is not connected to HDMI monitor and I want to see live video on laptop (192.168.178.62).

On Pi:

Code: Select all

gst-launch-1.0 -v rpicamsrc num-buffers=-1 ! video/x-raw,width=640,height=480, framerate=41/1 ! timeoverlay time-mode="buffer-time" ! jpegenc !  rtpjpegpay !  udpsink host=192.168.178.62 port=5200

On laptop:

Code: Select all

$ sudo /sbin/iptables -I INPUT 1 -p udp --dport 5200 -j ACCEPT
$ gst-launch-0.10 -v udpsrc port=5200 !  application/x-rtp, encoding-name=JPEG,payload=26 !  rtpjpegdepay !  jpegdec ! autovideosink

So change 192.168.178.62 to the IP address of your 2nd Pi, and run gst-launch-1.0 on it:

Code: Select all

$ gst-launch-1.0 -v udpsrc port=5200 !  application/x-rtp, encoding-name=JPEG,payload=26 !  rtpjpegdepay !  jpegdec ! autovideosink

The camera Pi pipeline adds timeoverlay. If you don't like that, remove it:
Image


P.S:
You can find more Raspberry gstreamer related information here:
https://stamm-wilbrandt.de/en/Raspberry ... #gstreamer
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

titusece
Posts: 69
Joined: Sat Sep 10, 2016 3:24 pm
Location: India

Re: Raspberry pi camera streaming

Tue May 15, 2018 2:04 pm

Thanks for your reply.

When I run the below command in one rpi, getting the below error.

Code: Select all

pi@raspberrypi:~ $ gst-launch-1.0 -v udpsrc port=5200 !  application/x-rtp, encoding-name=JPEG,payload=26 !  rtpjpegdepay !  jpegdec ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
WARNING: from element /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0: Could not initialise Xv output
Additional debug info:
xvimagesink.c(1760): gst_xv_image_sink_open (): /GstXvImageSink:autovideosink0-actual-sink-xvimage:
Could not open display (null)
Setting pipeline to PLAYING ...
New clock: GstSystemClock
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:03.083189207
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
pi@raspberrypi:~ $ 
Got the below error on another camera rpi.

Code: Select all

pi@raspberrypi:~/$ 
pi@raspberrypi:~/gst-rpicamsrc $ gst-launch-1.0 -v rpicamsrc num-buffers=-1 ! video/x-raw,width=640,height=480, framerate=41/1 ! timeoverlay time-mode="buffer-time" ! jpegenc !  rtpjpegpay !  udpsink host=192.168.178.62 port=5200
WARNING: erroneous pipeline: no element "rpicamsrc"
pi@raspberrypi:~/$ 
Can you please let me know how to install the rpicamsrc ?

Thanks for the help.

I am referring to this link for rpicamsrc pipeline building.
https://pastebin.com/S1zGK9kP

titusece
Posts: 69
Joined: Sat Sep 10, 2016 3:24 pm
Location: India

Re: Raspberry pi camera streaming

Tue May 15, 2018 2:38 pm

And also, I have used the below commands for streaming, looks like working except one error.


RPI1:
raspivid -t 999999 -h 720 -w 1080 -fps 25 -b 2000000 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! udpsink host=192.168.0.89 port=5000

RPI2:
gst-launch-1.0 -v udpsrc port=5000 ! gdpdepay ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink sync=false

Error: "xvimagesink.c(1760): gst_xv_image_sink_open (): /GstXvImageSink:autovideosink0-actual-sink-xvimage:
Could not open display (null)
"

Code: Select all

pi@raspberrypi:~ $ 
pi@raspberrypi:~ $ gst-launch-1.0 -v udpsrc port=5000  ! gdpdepay !  rtph264depay ! h264parse ! avdec_h264 ! autovideosink sync=false
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
WARNING: from element /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0: Could not initialise Xv output
Additional debug info:
xvimagesink.c(1760): gst_xv_image_sink_open (): /GstXvImageSink:autovideosink0-actual-sink-xvimage:
Could not open display (null)
Setting pipeline to PLAYING ...
New clock: GstSystemClock

BTW, I am using the lite version of raspian image. Do we need X server for the gstreamer output ?
I think, no, we can also should be able to stream in non-X window system.

Can you please help on this ?

titusece
Posts: 69
Joined: Sat Sep 10, 2016 3:24 pm
Location: India

Re: Raspberry pi camera streaming

Wed May 16, 2018 1:18 pm

The following commands are worked.

RPI1: (camera connected)
raspivid -t 999999 -h 720 -w 1080 -fps 25 -b 2000000 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! udpsink host=192.168.0.89 port=5000

RPI2:
gst-launch-1.0 -v udpsrc port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! fbdevsink sync=false

Thanks everyone for your help.

User avatar
HermannSW
Posts: 5178
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Raspberry pi camera streaming

Fri May 18, 2018 5:37 am

titusece wrote:
Tue May 15, 2018 2:04 pm
Can you please let me know how to install the rpicamsrc ?

Thanks for the help.

I am referring to this link for rpicamsrc pipeline building.
https://pastebin.com/S1zGK9kP
I met rpicamsrc author Jan Schmidt (thaytan) on GStreamer 2017 conference in Prague.
Please take his code from github, you will find installation instructions in README file:
https://github.com/thaytan/gst-rpicamsrc

I did compare performance of gstreamer pipelining. PIPEing raspivid to gstreamer pipeline was worst, v4l2 was better, best was rpicamsrc.
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Return to “General discussion”