Using gstreamer1.0 on Raspberry Pi 3B

Hello!
i want to add a new H264 camera on the Pi, so i installed gstreamer on a pretty new Pi(using the official mirror) and enter:
$ gst-launch-1.0 -v fdsrc ! video/x-h264,width=1080,height=720,framerate=24/1 ! h264parse ! queue ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.2.1 port=5600

my PC(win10) : python2.7 with module gi and some other required packages. So i use the example code in OpenCV · GitBook run it in the cmd, no error, but don’t have the video.

what kind of command should i use in Pi?

some other message:
i have set the wired network Ethernet of my PC and Pi to the static IP:192.168.2.1 192.168.2.2.
i did not open the QGC on my PC.

I’m sorry about my poor English. Thank you!

Hi,

Try with videotestsrc first.

gst-launch-1.0 videotestsrc ! video/x-raw,width=640,height=480 ! videoconvert ! x264enc ! rtph264pay ! udpsink host=192.168.2.1 port=5600

Thank you for your advice. i have tried the command you suggest and as a result i got the test video on my PC. Then i tried to use the H264 camera. i got the camera video when i run the command below:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480 ! x264enc ! queue ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.2.1 port=5600

but a new problem: big delay, about 4 seconds. Then i find the configuration in /camera:

! h264parse
! queue
! rtph264pay config-interval=10 pt=96
! udpsink host=192.168.2.1:5600

so i add these in the command:

gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480 ! h264parse ! queue ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.2.1 port=5600

return an error: Warning: Bad pipeline: Unable to link v4l2src0 to h264parse0 but i think these parts are necessary.
so i try this command:

gst-launch-1.0 -v fdsrc ! video/x-h264,width=640,height=480,framerate=24/1 ! h264parse ! queue ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.2.1 port=5600

from https://discuss.bluerobotics.com/t/ardusub-submodules/194/15?u=rimu
with no error, but don’t have the video. just no response.

On my personal computer, I have always used the python code copied from the website:OpenCV · GitBook.
i have tried all i found but didn’t work. what should i do then? Thank you!

Hi,

fdsrc only works with files or pipes, check the complete pipeline from the post that you are talking about.

Thank you for your reply. but i don’t understand what you mean and actually i don’t know how to check the pipeline. In fact, i even don’t understand what these commands mean now. i want to find a command run on the RPi which matches that python code.
i think :

gst-launch-1.0 -v ; width=640,height=480 ; ! h264parse ; ! queue ; ! rtph264pay config-interval=10 pt=96 ; ! udpsink host=192.168.2.1 port=5600

these parts are necessary. but what about the others.
So what kind of command is run in ArduSub?
Thank you!

Hi,

I would recommend to take some time and read more about gstreamer before building pipelines from scratch and dealing with weird errors.

  1. Gstreamer tutorial
  2. Identify and deal with gstreamer elements.
    And others.

Companion runs this pipeline:

 gst-launch-1.0 -v v4l2src device=$DEVICE do-timestamp=true
! video/x-h264, width=$WIDTH, height=$HEIGHT, framerate=$FRAMERATE/1
! h264parse
! queue
! rtph264pay config-interval=10 pt=96
! udpsink host=192.168.2.255 port=5600

Where DEVICE is the camera: E.g: /dev/video0
WIDTH the width resolution: E.g: 1920
HEIGHT the height resolution: E.g: 1080
FRAMERATE the camera framerate : E.g: 30

The user can configure any parameter, but this depends of the camera capabilities.

1 Like

by now, i have achieved to get the video om my PC, but the pronlem is that there is a large delay, so i try to find a way to deal with this.
i have tested the python code with my bluerov. as a result, the delay was very small.
Thank you for your soon reply and your advice. i plan to take some time to learn the gstreamer, then come back to solve this problem.
Thank you for your help!

1 Like