Research-documentation for H264-encoding and streaming with Raspberry Pis.

gstreamer

MPEGTS per UDP with Forward-Error-Correction (FEC) a la SMPTE 2022-1

Since 2020 there is an implementation of SMPTE 2022-1 in gstreamer: blog-post by Mathieu.

Documentation: rtpst2022-1-fecdec, rtpst2022-1-fecenc

SMPTE2022-1 Streaming with Auvidea B101 HDMI-CSI2-Bridge, audio and display-loop-out included

Tested by wtf with an Raspberry Pi 4B+ with Raspberry Pi OS 2023-10-10, Debian Bookworm each, in March 2024.

Works well per multicast as per unicast.

Latency: 1-1.1 Seconds

Receiver needs a static route towards 224.0.0.0/4 on eth0 in order to receive multicast.

Receiver needs to be started before (first) launch of sender. Help needed! Issue at Mathieu.

I/O-mode = auto. Result unclear, it seems popular stating DMAbuf here. Investigate!

The iframe-peroid of 2 frames is quiet aggressive.

Don't forget to remove “netsim drop-probability=0.01” before flight!

Sender, using Audio from HDMI-In and sending video-input to display:

gst-launch-1.0 \ rtpbin name=rtp fec-encoders='fec,0=“rtpst2022-1-fecenc\ rows\=4\ columns\=4”;' \ v4l2src device=/dev/video0 io-mode=0 do-timestamp=true ! “video/x-raw,framerate=30/1,format=UYVY,colorimetry=bt601” ! \ tee name=input ! \ v4l2h264enc output-io-mode=0 extra-controls=“controls,h264profile=4,h264level=11,videobitrate=15000000,videobitratemode=0,h264iframeperiod=2;” ! “video/x-h264,profile=high, level=(string)4” ! h264parse ! \ mpegtsmux name=mux ! rtpmp2tpay ssrc=0 ! rtp.sendrtpsink0 \ rtp.sendrtpsrc0 ! udpsink host=224.0.23.1 port=5000 multicast-iface=eth0 \ rtp.sendfecsrc00 ! udpsink host=224.0.23.1 port=5002 async=false multicast-iface=eth0 \ rtp.sendfecsrc_0_1 ! udpsink host=224.0.23.1 port=5004 async=false multicast-iface=eth0 \ alsasrc device=hw:tc358743 do-timestamp=true ! audio/x-raw,format=S16LE,rate=48000,channels=2 ! audioconvert ! voaacenc bitrate=48000 ! aacparse ! queue ! mux. \ input. ! queue ! videoconvert ! fbdevsink device=“/dev/fb0” sync=false

Receiver, with audio-out on Headphone-jack:

gst-launch-1.0 \
rtpbin latency=100 fec-decoders='fec,0="rtpst2022-1-fecdec\ size-time\=100000000";' name=rtp \
udpsrc address=224.0.23.1 port=5002 caps="application/x-rtp, payload=96" ! queue ! rtp.recv_fec_sink_0_0 \
udpsrc address=224.0.23.1 port=5004 caps="application/x-rtp, payload=96" ! queue ! rtp.recv_fec_sink_0_1 \
udpsrc address=224.0.23.1 port=5000 caps="application/x-rtp, media=video, clock-rate=90000, encoding-name=mp2t, payload=33" ! \
queue ! netsim drop-probability=0.01 ! rtp.recv_rtp_sink_0 \
rtp. ! queue ! decodebin name=decode ! videoconvert ! queue ! kmssink \
decode. ! audioconvert ! queue ! alsasink card-name="bcm2835 Headphones"