RTSP Streaming
Qualcomm Dragonwing™ RB3 Gen 2 RTSP Camera Streaming with Qualcomm Linux 1.3 AI Sample Application Demo on Qualcomm Device Cloud
How to do RTSP camera streaming on the Qualcomm Dragonwing™ RB3 Gen 2 devices?
The Qualcomm Linux AI sample applications can take camera, file, and RTSP stream input sources and outputs. Since you will be using a remote RB3 Gen 2 in Qualcomm Device Cloud, RTSP camera streaming will allow you to stream a live camera input from your local machine (e.g. a webcam, attached USB camera, or local network RTSP server) and output to a RTSP camera stream for playback on your local machine.

Prerequisites
- Qualcomm Dragonwing™ RB3 Gen 2 device with Qualcomm Linux 1.3+ and QIMSDK
- Multi-input AI inferencing AI sample application (included in the QIMSDK)
- FFmpeg: For capturing attached cameras into an output RTSP stream.
- Camera capture: Windows DirectShow, video4linux2, and OS X AVFoundation
- The OS specific ffmpeg documentation also provides commands to find the camera name and pixel format depending on the camera hardware.
- mediamtx: A simple RTSP server for proxying the local machine camera stream.
- Download the Linux ARM64 V8 release.
Instructions
-
Start a QDC Interactive Session with a RB3 Gen 2 device.
- Upload or choose an existing SSH public key for the interactive session to enable SSHing to the RB3 Gen 2 device.
-
In the running interactive session, click on the Connect button to view the SSH instructions to connect to the device.
- The additional ports mentioned in the last section of the instructions will be needed for RTSP camera streaming.
- Connect to the RB3 Gen 2 device with SSH. For example:
# Port 5037 is the ADB server# Port 8900 will be used for the mediamtx RTSP server# Port 8901 will be used by the GStreamer RTSP server# Port 22 is the RB3 Gen 2's SSH server which will be reached via localhost port 2222ssh -i <PRIVATE_KEY_FILE_PATH> -L 5037:sa<session>.sa.svc.cluster.local:5037 -L 2222:sa<session>.sa.svc.cluster.local:22 -L 8900:sa<session>.sa.svc.cluster.local:8900 -L 8901:sa<session>.sa.svc.cluster.local:8901 -N sshtunnel@ssh.qdc.qualcomm.com -
Check if you can SSH to the device. Alternatively, you may use
adb shell
andadb push
if preferred.ssh
andscp
has replacedadb
in the Qualcomm Linux 1.3 documentation.ssh -i <PRIVATE_KEY_FILE_PATH> -p 2222 -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null root@localhost -
Copy the mediamtx tarball file downloaded from the prerequisites section to the device:
# e.g. mediamtx_v1.11.3_linux_arm64v8.tar.gzscp -i <PRIVATE_KEY_FILE_PATH> -P 2222 -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null <local_file_location>/mediamtx_<version>_linux_arm64v8.tar.gz root@localhost:/opt/mediamtx.tar.gzRun the following in
ssh
:# In an ssh sessioncd /opttar -xf /opt/mediamtx.tar.gzEdit the mediamtx.yml file so the RTSP server port is one of the opened output ports you will be using (i.e. 8900-8909):
# In an ssh sessionvi /opt/mediamtx.ymlmediamtx.yml snippet example:
################################################ Global settings -> RTSP server# Enable publishing and reading streams with the RTSP protocol.rtsp: yes# List of enabled RTSP transport protocols....# Address of the TCP/RTSP listener. This is needed only when encryption is "no"rtspAddress: :8554Change the
rtspAddress: :8554
portion:# Address of the TCP/RTSP listener. This is needed only when encryption is "no"rtspAddress: :8901Alternatively, you can edit the file on your local machine before pushing to the RB3 Gen 2 device.
-
Export and push your YOLOv5 model generated from the Qualcomm Linux 1.3 documentation for the Multi-input AI inferencing sample application.
scp -i <PRIVATE_KEY_FILE_PATH> -P 2222 -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null yolov5.labels root@localhost:/opt/yolov5.labelsscp -i <PRIVATE_KEY_FILE_PATH> -P 2222 -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null yolov5.tflite root@localhost:/opt/yolov5.tflite -
Start the mediamtx RTSP server on the RB3 Gen 2.
# Run in an ssh sessioncd /opt./mediamtx -
Use FFmpeg to send a local RTSP camera stream to the mediamtx RTSP server. See prerequisites for details for running FFmpeg camera capture on other operating systems. For example, on a Windows laptop with a webcam named "Integrated Camera":
ffmpeg -f dshow -video_size 640x480 -pixel_format yuyv422 -i video="Integrated Camera" -framerate 15 -tune zerolatency -vf format=yuv420p -c:v h264 -crf 10 -f rtsp -muxdelay 0 -rtsp_transport tcp rtsp://127.0.0.1:8901/mystream/live1.mkvSee prerequisites for details for running FFmpeg camera capture on other operating systems or how to list available camera sources. Note: The "live1.mkv" part of the URL is expected from the gst-ai-multi-input-output-object-detection sample application.
-
Create the weston.ini config file and run Weston.
# Start a new ssh sessionmkdir -p /etc/xdg/westontouch /etc/xdg/westonvi /etc/xdg/weston/weston.iniPaste the following options into weston.ini to allow Weston to run without an output display.
# configuration file for Weston[core]idle-time=0backend=drm-backend.sorepaint-window=10gbm-format=xbgr8888require-outputs=none[output]name=DSI-1mode=on[output]name=DP-1mode=on[shell]clock-format=secondsNow run Weston as indicated in the Qualcomm Linux documentation:
export GBM_BACKEND=msm && export XDG_RUNTIME_DIR=/dev/socket/weston && mkdir -p $XDG_RUNTIME_DIR && weston --continue-without-input --idle-time=0 -
Start the GStreamer AI multi input output object detection sample application with the instructions from the Qualcomm Linux AI sample application documentation.
# Start a new ssh session# Setup some environment variables in the SSH session for displayexport XDG_RUNTIME_DIR=/dev/socket/weston && export WAYLAND_DISPLAY=wayland-1# Run the GStreamer AI multi input output object detection sample applicationgst-ai-multi-input-output-object-detection --num-rtsp=1 --rtsp-ip-port=127.0.0.1:8901/mystream --out-rtsp -i 127.0.0.1 -p 8900 -
Playback the output stream on local machine with FFplay (part of FFmpeg):
ffplay -probesize 32 -analyzeduration 0 -sync ext -fflags nobuffer -flags low_delay -x 640 -y 480 -rtsp_transport tcp rtsp://127.0.0.1:8900/liveAlternatively, use a video player like VLC that can play RTSP streams from over the network.