Here are the basic instructions to stream a video from the imx415 camera using rtsp protocol.
For the instructions, i am using Debian 11.5 with X11, but it really does not matter which distro.
ROCK 5B IP: 192.168.254.228 (our server)
Client IP: 92.168.254.200 (our client where we display the camera content)
pre-requisites
- rkmpp encoding capabilities (hw encode enabled)
- imx415 camera
- gstreamer with the rkmpp plugin
For learning purposes, i have built the gstreamer rtsp server.
Checking gstreamer encoder:
sudo gst-inspect-1.0|grep -i rock
rockchipmpp: mppjpegdec: Rockchip's MPP JPEG image decoder
rockchipmpp: mppvideodec: Rockchip's MPP video decoder
rockchipmpp: mppjpegenc: Rockchip Mpp JPEG Encoder
rockchipmpp: mppvp8enc: Rockchip Mpp VP8 Encoder
rockchipmpp: mpph265enc: Rockchip Mpp H265 Encoder
rockchipmpp: mpph264enc: Rockchip Mpp H264 Encoder
Build gstreamer rtsp server:
mkdir -p rockchip/gstreamer/rtsp-server
cd rockchip/gstreamer/rtsp-server/
wget https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-1.18.4.tar.xz
tar -xf gst-rtsp-server-1.18.4.tar.xz
cd gst-rtsp-server-1.18.4
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.18.4" ..
ninja -j4
sudo ninja install
sudo ldconfig
Testing our rtsp server with videotestsrc:
cd example
~/rockchip/gstreamer/rtsp-server/gst-rtsp-server-1.18.4/build/examples$
sudo ./test-launch "( videotestsrc ! video/x-raw,format=NV12,width=1920,height=1080 ! mpph264enc ! rtph264pay name=pay0 pt=96 )"
stream ready at rtsp://127.0.0.1:8554/test
rga_api version 1.8.1_[0]
From our client, we check if it is OK, here we use ffplay:
ffplay -rtsp_transport tcp rtsp://192.168.254.228:8554/test
Now we have the video displayed with some patterns.
We can now stream our video:
~/rockchip/gstreamer/rtsp-server/gst-rtsp-server-1.18.4/build/examples$
sudo ./test-launch "( v4l2src device=/dev/video11 io-mode=dmabuf ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! mpph264enc ! rtph264pay name=pay0 pt=96 )"
stream ready at rtsp://127.0.0.1:8554/test
rga_api version 1.8.1_[0]
Again, we display the content using ffplay with the same URI:
ffplay -rtsp_transport tcp rtsp://192.168.254.228:8554/test
ffplay version 5.0 Copyright (c) 2003-2022 the FFmpeg developers
built with gcc 8 (Ubuntu 8.4.0-1ubuntu1~18.04)
configuration: --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopus --enable-libpulse --enable-librsvg --enable-librtmp --enable-libv4l2 --enable-libvorbis --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-libxcb-shape --enable-libxvid --enable-libxml2 --enable-opengl --enable-openssl --enable-gpl --enable-nonfree --disable-librga
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Input #0, rtsp, from 'rtsp://192.168.254.228:8554/test': 0B f=0/0
Metadata:
title : Session streamed with GStreamer
comment : rtsp-server
Duration: N/A, start: 0.034367, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 30 fps, 30 tbr, 90k tbn
72.28 M-V: -0.005 fd= 2 aq= 0KB vq= 360KB sq= 0B f=0/0
Have fun!
CPU usage: