> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up RTSP

> Set up an RTSP server and stream video to and from a Qualcomm Device Cloud device

1. Download the [MediaMTX](https://github.com/bluenviron/mediamtx) utility to set up an RTSP listening server.

   The following steps are verified for MediaMTX version `v1.11.3_linux_arm64v8`, available at
   [mediamtx\_v1.11.3\_linux\_arm64v8.tar.gz](https://github.com/bluenviron/mediamtx/releases/download/v1.11.3/mediamtx_v1.11.3_linux_arm64v8.tar.gz).

2. Unzip the downloaded archive and edit the `mediamtx.yml` file to enable RTSP streaming on port `8901`.

   ```yaml theme={null}
   ###############################################
   # Global settings -> RTSP server

   # Enable publishing and reading streams with the RTSP protocol.
   rtsp: yes

   # List of enabled RTSP transport protocols.
   # UDP is the most performant, but doesn't work when there's a NAT/firewall between
   # server and clients, and doesn't support encryption.
   # UDP-multicast allows to save bandwidth when clients are all in the same LAN.
   # TCP is the most versatile, and does support encryption.
   # The handshake is always performed with TCP.
   rtspTransports: [udp, multicast, tcp]

   # Encrypt handshakes and TCP streams with TLS (RTSPS).
   # Available values are "no", "strict", "optional".
   rtspEncryption: "no"

   # Address of the TCP/RTSP listener. This is needed only when encryption is "no" or "optional".
   rtspAddress: :8901

   # Address of the TCP/TLS/RTSPS listener. This is needed only when encryption is "strict" or "optional".
   rtspsAddress: :8322
   ```

3. Copy the `mediamtx.yml` file and the `mediamtx` executable to the device:

   ```shell theme={null}
   scp -P 2222 -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null <mediamtx path>/mediamtx root@localhost:/opt
   ```

   ```shell theme={null}
   scp -P 2222 -o StrictHostKeychecking=no -o UserKnownHostsFile=/dev/null <mediamtx path>/mediamtx.yml root@localhost:/opt
   ```

4. Open a new SSH shell and run the `mediamtx` utility:

   ```shell theme={null}
   cd /opt
   chmod +x mediamtx
   ./mediamtx
   ```

   <img src="https://mintcdn.com/qualcomm-prod/ajmq44Q1W0vLtUT4/Tools/Qualcomm-Device-Cloud/_images/qdc/execute-mediamtx.png?fit=max&auto=format&n=ajmq44Q1W0vLtUT4&q=85&s=3c386854f82e10148ae3e040b3fe2555" alt="MediaMTX utility running on the device" width="2560" height="1440" data-path="Tools/Qualcomm-Device-Cloud/_images/qdc/execute-mediamtx.png" />

5. Start an RTSP stream on your host computer on localhost at port `8901`.

   The following example uses [FFmpeg](https://ffmpeg.org/) to capture input from a connected webcam and send it as an RTSP stream. If FFmpeg is not installed, [download it](https://ffmpeg.org/download.html) from the FFmpeg website.

   ```shell theme={null}
   ffmpeg -f dshow -video_size 640x480 -i video="Integrated Camera" -framerate 15 -vf format=yuv420p -c:v h264 -f rtsp -rtsp_transport tcp rtsp://127.0.0.1:8901/live1.mkv
   ```

   <img src="https://mintcdn.com/qualcomm-prod/ajmq44Q1W0vLtUT4/Tools/Qualcomm-Device-Cloud/_images/qdc/ffmpeg-cmd.png?fit=max&auto=format&n=ajmq44Q1W0vLtUT4&q=85&s=6a961e118aebcc592b1bb917cee2555c" alt="FFmpeg command for RTSP streaming" width="2560" height="1440" data-path="Tools/Qualcomm-Device-Cloud/_images/qdc/ffmpeg-cmd.png" />

6. Verify the RTSP stream output using VLC media player:

   1. Open VLC media player.
   2. Press `Ctrl+N`.
   3. Enter the URL `rtsp://127.0.0.1:8901/live1.mkv` in the input bar.
   4. Select **Play**.

   <img src="https://mintcdn.com/qualcomm-prod/ajmq44Q1W0vLtUT4/Tools/Qualcomm-Device-Cloud/_images/qdc/rtsp-vlc-output.png?fit=max&auto=format&n=ajmq44Q1W0vLtUT4&q=85&s=11843843755ba15c4e0a5bf831f3142a" alt="RTSP stream output in VLC media player" width="1920" height="1128" data-path="Tools/Qualcomm-Device-Cloud/_images/qdc/rtsp-vlc-output.png" />
