Push an H.264 RTSP stream from a USB camera on RK3399Pro — using the live555 server framework plus the Rockchip MPP hardware encoder and RGA. Translated and annotated from hisping, Rockchip / Toybrick community, including the common RGA/MPP version-mismatch pitfall and how to fix it.
The original tutorial builds a small RTSP server on the TB-RK3399ProD board that captures frames from a USB camera, hardware-encodes them to H.264 with Rockchip MPP, and serves the stream over RTSP so a remote player (VLC) can display it. The key idea — and the part worth stealing — is that the video encode runs on the Rockchip hardware encoder through MPP, not on the CPU. The thread notes a 3-hour soak test ran clean on the demo; for commercial products you should still do your own optimization. You can also swap live555 for another RTSP framework and keep the same MPP encode path.
rockchip-mpp GStreamer plugins or rkmpp directly. Bestom builds RK3588/RK3576 SoM and reference designs and can help you stand up a camera + streaming path — see Solutions → Smart Vision.
The tutorial was verified on Fedora 28 (firmware v1.5) and also on Debian 10. Install the live555, FFmpeg, and Rockchip MPP/RGA development packages.
sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install live555-devel
sudo dnf install ffmpeg-devel
sudo dnf install librockchip_mpp-devel
sudo dnf install librockchip_rga-devel
First refresh the package indexes (the first update pulls in the Toybrick apt source):
# 1. refresh sources
sudo apt update --fix-missing
# 2. upgrade packages
# NOTE: during the upgrade you will be asked whether to keep
# /etc/apt/sources.list.d/toybrick.list — answer "Y"
sudo apt -y upgrade
# 3. refresh sources again
sudo apt update
For later updates, a plain sudo apt update && sudo apt upgrade is enough. Then install the dependencies:
sudo apt install liblivemedia-dev
sudo apt install livemedia-utils
sudo apt install ffmpeg
sudo apt install libavcodec-dev
sudo apt install libswscale-dev
sudo apt install libavformat-dev
sudo apt install vlc
sudo apt install rockchip-mpp-dev
sudo apt install rockchip-rga-dev
apt/dnf upgrade can pull a newer mpp/rga/drm than your kernel BSP expects and break the encoder. Pin or vendor the exact versions your SoM firmware was built against — Bestom ships MPP/RGA versions aligned to each RK3588/RK3576 BSP release for this reason.
Download and extract the attachment for your distro (Fedora or Debian), then build inside the IPCamera/ directory:
cd IPCamera/
make clean
make
./RTSPServer
On startup the server prints the RTSP URL — the IP is whatever the board got, so use the printed value. In the original run it was:
rtsp://172.16.9.3:8554/h264ESVideoTest
Keep this URL; the player uses it in the next step.
The tutorial installs VLC right on the board, but you can also play from a PC on the same network:
sudo dnf install vlc
vlc
In VLC: Media → Open Network Stream → paste rtsp://172.16.9.3:8554/h264ESVideoTest → Play.
V4L2FramedSource::doGetNextFrame() pulls one frame from the USB camera (UVC) and converts it to NV12 for the encoder:
void V4L2FramedSource::doGetNextFrame() {
long bigin = get_time();
registerOutputInterest();
while(fTotOfFrameToSend < fMaxOfFrameToSend) {
convernt_to_OutputBuffer();
}
long end = get_time();
printf("V4L2FramedSource::doGetNextFrame use %d \n", end - bigin);
// record the returned info
fFrameSize = fNumValidDataBytes; // one frame per call
fNumTruncatedBytes = 0;
reset();
afterGetting(this);
}
StreamEncoder::continueReadProcessing1() calls the Rockchip MPP library to encode the NV12 frame to H.264:
void StreamEncoder::continueReadProcessing1(unsigned frameSize, unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds) {
fNumTruncatedBytes = numTruncatedBytes;
fPresentationTime = presentationTime;
fDurationInMicroseconds = durationInMicroseconds;
encoder_to_h264();
if (fNumValidDataBytes + dstsize < fOutputBufferSize && fTotOfFrameToSend < fMaxOfFrameToSend) {
copy_to_outputbuffer();
}
fFrameSize = fNumValidDataBytes;
gettimeofday(&fPresentationTime, NULL);
reset();
FramedSource::afterGetting(this);
}
V4L2.cpp, encode in StreamEncoder.cpp — is a clean pattern to port. On RK3588/RK3576 the MPP API is the same family, and RGA2 does the YUYV→NV12 (or other) conversion. If your camera already outputs NV12 or MJPEG you can skip the RGA step and feed MPP directly, saving a copy. Bestom's camera reference designs use exactly this MPP encode path and can hand you a working StreamEncoder for your sensor.
The thread's replies contain a genuinely useful debugging record. Two failure modes came up repeatedly:
| Symptom | Cause | Fix (from the thread) |
|---|---|---|
Open file(/boot/toybrick-release) failed then rgaCreate error! on startup | The system rga package (installed via apt/dnf) is incompatible with the board's BSP | Build RGA from the "RK3399Pro Tutorial (5): Using the RGA graphics-acceleration engine" source: copy that project's rockchip_rga/ folder into the RTSP project root, put its headers into include/, add the generated .o files to the Makefile, and remove the rockchip/ path prefix from #include <rockchip/rockchip_rga.h>. |
Same RGA error after a routine dnf update | mpp, rga, and drm libraries were upgraded to versions newer than the BSP | Downgrade mpp, rga, and drm back to the versions that shipped with the firmware. |
| Stream stutters / freezes when viewed over the LAN from a PC (e.g. via OpenCV) | Demo-level pipeline; not tuned for high-load network playback | Treat as a teaching example; for production, tune the RTSP server, buffer, and bitrate, or move to a maintained server (e.g. rkmpp + a lightweight RTSP server). |
rgaCreate error.