Setting Up a RTSP Test Server for Video Streaming

Bandwidth size

This guide will walk you through the steps required to configure and launch a simple RTSP server, which can be used to stream video content via RTSP as if it were an IP camera or a live broadcast.

Install Docker

To install Docker, you need to follow these steps based on your operating system:

For Windows:

  1. Download Docker Desktop for Windows from the official Docker website.
  2. Run the installer and follow the installation wizard's instructions.
  3. After installation, launch Docker Desktop from the Start menu.

For macOS:

  1. Download Docker Desktop for Mac from the official Docker website..
  2. Open the downloaded .dmg file and drag the Docker icon to the Applications folder.
  3. Run Docker from the Applications folder.

For Ubuntu 20.04:

  1. Ensure that your system packages are fully updated before installing curl using the commands provided below:
    $ sudo apt update & sudo apt upgrade 
    $ sudo apt install apt-transport-https curl
  2. Install Docker
    $ sudo apt install docker.io
  3. Installing Docker's service
    $ sudo systemctl enable docker 
    $ sudo systemctl start docker

Install FFmpeg

To install FFmpeg, you need to follow these steps based on your operating system:

Windows

  1. Download the FFmpeg build from the official website.
  2. Extract the downloaded ZIP file to a folder on your computer.
  3. Add the bin folder within the extracted folder to your system's PATH environment variable.
  4. Open Command Prompt and type ffmpeg -version to check if the installation was successful.

macOS

  1. Install Homebrew by running /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" in the Terminal.
  2. Once Homebrew is installed, you can install FFmpeg by running brew install ffmpeg in the Terminal.
  3. Type ffmpeg -version in the Terminal to confirm the installation.

Linux

  1. Open the Terminal.
  2. For Debian-based distributions, use sudo apt update followed by sudo apt install ffmpeg.
  3. For Red Hat-based distributions, use sudo yum install ffmpeg.
  4. For Arch-based distributions, use sudo pacman -S ffmpeg.
  5. Type ffmpeg -version to verify the installation.

Install VLC

To launch VLC using the command line, it should be properly installed.

  • For Windows:

    Download the installer from the VLC official website and follow the installation instructions.

  • For macOS:

    Install using Homebrew by running the command brew install --cask vlc in the terminal.

  • For Ubuntu 20.04:

    Install using APT by running the command sudo apt-get update followed by sudo apt-get install vlc.

Start the RTSP Server

To start the RTSP server, you need to run the following command from the terminal:

docker run --rm --detach \
-e MTX_PROTOCOLS=tcp \
-p 8554:8554 \
bluenviron/mediamtx:latest

The code above will launch the mediaMTX real-time media server.

What is mediaMTX?

MediaMTX, previously known as rtsp-simple-server, is a real-time media server and proxy that is immediately operational and requires no dependencies. It enables the publishing, consumption, relaying, recording, and playback of audio and video content. Designed as a "media router," it facilitates the transfer of media content between endpoints.

Why we need mediaMTX?

MediaMTX act as intermediate server between FFmpeg and VLC

Get a test video

You can download a test video from here.

Start FFmpeg

To start FFmpeg, you need to run the following command from the terminal:

ffmpeg -re -stream_loop -1 -i 60sec.mp4 -c copy -f rtsp rtsp://localhost:8554/stream

For additional commands you can follow the FFmpeg cheatsheet.

Open VLC

To start VLC, you need to run the following command from the terminal:

vlc --network-caching=5000 rtsp://localhost:8554/stream

Conclusion

Congratulations! 🚀

You have successfully set up and tested an RTSP server for video streaming using Docker.

If you need a ready-to-use RTSP test server instead of setting up your own, you can access it here: rtsp://rtsp-test-server.viomic.com:554/stream