RTSP Server streaming video with gstreamer on Zero 3W (testing)

I had time today to test the gstreamer rtsp server on my 3W.
The test here re-used an old Rock 3A rootfs i tuned some time ago, so i can say it is fully compatible with rk3568, the missing bit is the NPU.

1. Environment

Camera IMX219 120º - Streaming 1920x1080

lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.3 LTS
Release:	22.04
Codename:	jammy


ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 102  bytes 8652 (8.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 102  bytes 8652 (8.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.254.232  netmask 255.255.0.0  broadcast 192.168.255.255
        inet6 2804:7f4:322a:3049:f886:275c:2f76:6a9f  prefixlen 64  scopeid 0x0<global>
        inet6 2804:7f4:322a:3049:7995:b2b0:b9cc:1299  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::2ebb:ede:92fd:c7b  prefixlen 64  scopeid 0x20<link>
        inet6 2804:7f4:322a:3049:7d08:5033:c30e:1775  prefixlen 64  scopeid 0x0<global>
        inet6 2804:7f4:322a:3049:ba1a:8e12:c11e:fc4a  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::6b09:b810:c4ca:ebce  prefixlen 64  scopeid 0x20<link>
        ether 98:03:cf:c6:e5:9c  txqueuelen 1000  (Ethernet)
        RX packets 177717  bytes 12985990 (12.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 382347  bytes 552496728 (552.4 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Linux rzero-3w 5.10.160-imx219 #2 SMP Sun Jan 28 11:45:52 -03 2024 aarch64 aarch64 aarch64 GNU/Linux

Ambient Temp: 28ºC
Board Temp (idle):

cat /sys/devices/virtual/thermal/thermal_zone0/temp
58333

2. Minimum requirements

Kernel, RGA, MPP, gstreamer, and rockchip media must be up-to-date.

gst-inspect-1.0|grep -i rock
rkisp: rkisp: Gstreamer Plugin For Rockchip ISP Source
rockchipmpp: mpph264enc: Rockchip Mpp H264 Encoder
rockchipmpp: mpph265enc: Rockchip Mpp H265 Encoder
rockchipmpp: mppjpegdec: Rockchip’s MPP JPEG image decoder
rockchipmpp: mppjpegenc: Rockchip Mpp JPEG Encoder
rockchipmpp: mppvideodec: Rockchip’s MPP video decoder
rockchipmpp: mppvpxalphadecodebin: VP8/VP9 Alpha Decoder

3. Building gstreamer rtsp server

Build:

wget https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-1.20.3.tar.xz
tar -xf gst-rtsp-server-1.20.3.tar.xz gst-rtsp-server-1.20.3/
cd gst-rtsp-server-1.20.3/
mkdir build && cd build
meson --prefix=/usr --wrap-mode=nofallback -D buildtype=release -D package-origin=https://gstreamer.freedesktop.org/src/gstreamer/ -D package-name=“GStreamer 1.20.3” …
ninja -j4
sudo ninja install
sudo ldconfig

Run:

cd examples/
rock@rzero-3w:~/rockchip/gstreamer/rtsp-server/gst-rtsp-server-1.20.3/build/examples$
sudo ./test-launch “( v4l2src device=/dev/video0 io-mode=dmabuf ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! mpph264enc ! rtph264pay name=pay0 pt=96 )”

CPU Load and Temperature while running rtsp server after the compilation:

root@rzero-3w:/home/rock# top

    top - 13:06:31 up  2:31,  0 users,  load average: 2.32, 1.70, 1.00
    Tasks: 158 total,   1 running, 157 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  9.7 us, 16.7 sy,  0.0 ni, 72.4 id,  0.0 wa,  0.0 hi,  1.2 si,  0.0 st
    MiB Mem :   1977.7 total,   1053.8 free,    188.4 used,    735.6 buff/cache
    MiB Swap:      0.0 total,      0.0 free,      0.0 used.   1626.6 avail Mem 

        PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND  
       3812 root      20   0  718392  31344  15872 S  66.1   1.5   5:27.60 test-la+ 
        285 root      20   0 1081888   8556   4724 S  21.4   0.4   2:07.06 rkaiq_3+ 
        163 root      39  19       0      0      0 S   7.6   0.0   0:36.02 dmabuf-+ 
        180 root      rt   0       0      0      0 S   5.9   0.0   1:22.20 sugov:0  
        526 root      -2   0       0      0      0 S   2.3   0.0   0:13.71 aicwf_b+ 
        527 root      -2   0       0      0      0 S   1.6   0.0   0:10.35 aicwf_b+ 
       3940 root      20   0    7392   3208   2620 R   1.3   0.2   0:01.22 top      
         11 root      20   0       0      0      0 I   1.0   0.0   0:07.10 rcu_sch+ 
        149 root      20   0       0      0      0 S   1.0   0.0   0:05.27 queue_w+ 
        173 root      20   0       0      0      0 I   0.7   0.0   0:01.89 kworker+ 
        192 root     -51   0       0      0      0 S   0.7   0.0   0:03.87 irq/29-+ 
        196 root     -51   0       0      0      0 S   0.7   0.0   0:02.75 irq/35-+ 
       3951 root      20   0       0      0      0 I   0.7   0.0   0:00.73 kworker+ 
         10 root      20   0       0      0      0 S   0.3   0.0   0:01.41 ksoftir+ 
         32 root      20   0       0      0      0 I   0.3   0.0   0:05.56 kworker+ 
        193 root      20   0       0      0      0 I   0.3   0.0   0:00.79 kworker+ 
       1342 root      20   0       0      0      0 I   0.3   0.0   0:04.17 kworker+ 

    root@rzero-3w:/home/rock# cat /sys/devices/virtual/thermal/thermal_zone0/temp
    68125