Setting Up a RTSP Test Server for Video Streaming
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:
- Download Docker Desktop for Windows from the official Docker website.
- Run the installer and follow the installation wizard's instructions.
- After installation, launch Docker Desktop from the Start menu.
For macOS:
- Download Docker Desktop for Mac from the official Docker website..
- Open the downloaded .dmg file and drag the Docker icon to the Applications folder.
- Run Docker from the Applications folder.
For Ubuntu 20.04:
- 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 - Install Docker
$ sudo apt install docker.io
- 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
- Download the FFmpeg build from the official website.
- Extract the downloaded ZIP file to a folder on your computer.
- Add the bin folder within the extracted folder to your system's PATH environment variable.
- Open Command Prompt and type
ffmpeg -version
to check if the installation was successful.
macOS
- Install Homebrew by running
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
in the Terminal. - Once Homebrew is installed, you can install FFmpeg by running
brew install ffmpeg
in the Terminal. - Type
ffmpeg -version
in the Terminal to confirm the installation.
Linux
- Open the Terminal.
- For Debian-based distributions, use
sudo apt update
followed bysudo apt install ffmpeg
. - For Red Hat-based distributions, use
sudo yum install ffmpeg
. - For Arch-based distributions, use
sudo pacman -S ffmpeg
. - 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 bysudo 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