Skip to main content

RTSP Streaming

Requirements

  1. compatible camera
  2. If you use ROCK 5B, you can also use HDMI RX as the video source.

Server Configuration

tip

When using HDMI RX, input sources with lower than 720P resolution may cause encoding failure.
After testing, ffmpeg-rockchip is not compatible with the rkmpp and librga versions we released for Debian 11 systems, Debian 12 systems are not affected.
If you are using our Debian 11 system, please go to ffmpeg-rockchip official build tutorial , build rkmpp and librga and then build ffmpeg-rockchip.

Installation of compilation dependencies

sudo apt-get update
sudo apt-get install build-essential cmake git libdrm-dev librga-dev librockchip-mpp-dev libsdl2*-dev libx264-dev libx265-dev pkg-config

Compile and install ffmpeg-rockchip

git clone https://github.com/nyanmisaka/ffmpeg-rockchip
pushd ffmpeg-rockchip/
./configure --prefix=/usr --enable-gpl --enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga --enable-libx264 --enable-libx265 --enable-ffplay
make -j$(nproc)
sudo make install
popd

Running mediamtx and ffmpeg-rockchip

info

Here we assume that /dev/video-camera0 is the video source you want to use. If your camera is assigned a different name, replace the corresponding device name in the following command line.
-vf “fps=30” and -s 3840x2160 correspond to the frame rate and resolution respectively, which need to be adjusted according to the output of the command sudo v4l2-ctl -d /dev/video-camera0 --all, or else the encoding performance will be affected or even the startup of the push stream will fail due to the failure of reading the camera information automatically. The -c:v option specifies the encoder to be used, currently ffmpeg-rockchip supports h264_rkmpp, hevc_rkmpp and mjpeg_rkmpp hardware encoders.

wget https://github.com/bluenviron/mediamtx/releases/download/v1.9.0/mediamtx_v1.9.0_linux_arm64v8.tar.gz
tar -xzvf mediamtx_v1.9.0_linux_arm64v8.tar.gz
nohup ./mediamtx &
ffmpeg-rockchip/ffmpeg -f v4l2 -i /dev/video-camera0 -vf "fps=30" -s 3840x2160 -c:v h264_rkmpp -rc_mode AVBR -b:v 20M -minrate 10M -maxrate 40M -profile:v main -level 5.1 -f rtsp rtsp://0.0.0.0:8554/stream

# If you only want to record the camera to a file, use the following command
# ffmpeg-rockchip/ffmpeg -f v4l2 -i /dev/video-camera0 -vf "fps=30" -s 3840x2160 -c:v h264_rkmpp -rc_mode AVBR -b:v 20M -minrate 10M -maxrate 40M -profile:v main -level 5.1 /tmp/tmp.mp4

Client configuration

Using VLC Player

The following is an example of how to watch RTSP video stream by running VLC under Windows.

  1. Download and install VLC VLC-Main

  2. Click "Media - Open Network Streaming" to enter the RTSP stream address.

tip

A communicable IP address is necessary.

VLC-Open-RTSP

  1. Click Play to view the RTSP remote streaming content. VLC-View-RTSP

Using the ffplay player on a development board

It is also possible to play directly with the ffplay utility for FFmpeg mentioned above

tip

Should be replaced with the URL and IP address specified in the server command line.
The -vcodec option is the specified codec, please adjust it according to the encoding of the RTSP stream. The hardware decoders supported by ffmpeg-rockchip are av1_rkmpp, h263_rkmpp, h264_rkmpp, hevc_rkmpp, mpeg1_rkmpp, mpeg2_rkmpp, mpeg4_rkmpp, vp8_rkmpp, vp9_rkmpp.

ffmpeg-rockchip/ffplay -vcodec h264_rkmpp rtsp://192.168.10.9:8554/stream