Search code examples
raspberry-picameragstreamer

Raspberry Pi not able to receive and view stream from another Pi using gStreamer


I've got a double Pi setup. One 3b and one 4. The 4 is setup with the 7" raspberry pi screen. The 3b is setup with two cameras. I'll name these "sender" (3b) and "player" (4).

I'm trying to use gstreamer to send low latency video from the sender to the reciever. I've found and used this command on the sender:

gst-launch-1.0 v4l2src device=/dev/video0 ! \
    'video/x-raw, width=352, height=288, framerate=25/1' ! \
    videoconvert ! \
    x264enc pass=qual quantizer=20 tune=zerolatency ! \
    rtph264pay ! \
    multiudpsink clients="10.0.0.200:5600,10.0.0.178:5600"

And using this code on the receiver:

export DISPLAY=:0
gst-launch-1.0 -v udpsrc port=5600 ! application/x-rtp, payload=96 ! rtph264depay ! avdec_h264 ! autovideosink

So first I tested the receiver command on my Windows PC and it works flaweless. Sub 100ms delay and everything.

Now I test this on the receiver pi 4 and I get this:

pi@receiver4:~ $ gst-launch-1.0 -v udpsrc port=5600 ! application/x-rtp, payload=96 ! rtph264depay ! avdec_h264 ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

It stops here then I start the sender and the following happens:

/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = application/x-rtp, payload=(int)96, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264
/GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0.GstPad:sink: caps = application/x-rtp, payload=(int)96, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264

/GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0.GstPad:src: caps = video/x-h264, stream-format=(string)avc, alignment=(string)au, codec_data=(buffer)017a000dffe1001b677a000dbcb202c12d80a506060640000003004000000ca3c50a9201000668ebc1b2c8b0, level=(string)1.3, profile=(string)high-4:2:2
/GstPipeline:pipeline0/avdec_h264:avdec_h264-0.GstPad:sink: caps = video/x-h264, stream-format=(string)avc, alignment=(string)au, codec_data=(buffer)017a000dffe1001b677a000dbcb202c12d80a506060640000003004000000ca3c50a9201000668ebc1b2c8b0, level=(string)1.3, profile=(string)high-4:2:2
/GstPipeline:pipeline0/avdec_h264:avdec_h264-0.GstPad:src: caps = video/x-raw, format=(string)Y42B, width=(int)352, height=(int)288, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)mpeg2, colorimetry=(string)bt601, framerate=(fraction)25/1
Redistribute latency...
ERROR: from element /GstPipeline:pipeline0/GstUDPSrc:udpsrc0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstUDPSrc:udpsrc0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:03.494063865
Setting pipeline to NULL ...
Freeing pipeline ...

So why is this not streaming on the raspberry pi screen as it does on my windows screen? I tested with the test video src and I get a window with the expected output:

export DISPLAY=:0
gst-launch-1.0 videotestsrc ! autovideosink

enter image description here


Solution

  • You may try this as sender:

    gst-launch-1.0 videotestsrc do-timestamp=1 is-live=1 ! video/x-raw, width=352, height=288, framerate=25/1 ! videoconvert ! x264enc pass=qual quantizer=20 tune=zerolatency insert-vui=1 key-int-max=16 ! h264parse ! rtph264pay ! udpsink host=<target_host_IP_v4_or_v6> port=5004 -ev
    

    and this as receiver:

    gst-launch-1.0 udpsrc address=<same_IP_v4_or_v6_address> port=5004 ! application/x-rtp,media=video,encoding-name=H264,clock-rate=90000 ! rtpjitterbuffer latency=300 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! autovideosink -v
    

    In case the network between both RPi is wifi, you may also try disabling updsink auto-multicast property.