mediamtx is a ready-to-use and zero-dependency server and proxy that allows users to publish, read and proxy live video and audio streams through various protocols:
protocol | description | publish | read | proxy |
---|---|---|---|---|
RTSP | fastest way to publish and read streams | ✔️ | ✔️ | ✔️ |
RTMP | allows to interact with legacy software | ✔️ | ✔️ | ✔️ |
HLS | allows to embed streams into a web page | ❌ | ✔️ | ✔️ |
Features:
- Publish live streams to the server
- Read live streams from the server
- Act as a proxy and serve streams from other servers or cameras, always or on-demand
- Each stream can have multiple video and audio tracks, encoded with any codec, including H264, H265, VP8, VP9, MPEG2, MP3, AAC, Opus, PCM, JPEG
- Streams are automatically converted from a protocol to another. For instance, it's possible to publish a stream with RTSP and read it with HLS
- Serve multiple streams at once in separate paths
- Authenticate users; use internal or external authentication
- Query and control the server through an HTTP API
- Read Prometheus-compatible metrics
- Redirect readers to other RTSP servers (load balancing)
- Run external commands when clients connect, disconnect, read or publish streams
- Reload the configuration without disconnecting existing clients (hot reloading)
- Compatible with Linux, Windows and macOS, does not require any dependency or interpreter, it's a single executable
sudo apt-get update
sudo apt-get upgrade
sudo reboot -h now
For AWS E2 use Linux 22.04 LTS t3.large (2v CPU and 8GB RAM) For AWS LightSail use Linux_AMD64
wget https://github.com/aler9/mediamtx/releases/download/v1.0.0/mediamtx_v1.0.0_linux_amd64.tar.gz
tar -zxvf mediamtx_v1.0.0_linux_amd64.tar.gz
sudo chmod a+rwx /usr/local/etc/
sudo cp mediamtx /usr/local/bin/mediamtx
sudo cp mediamtx.yml /usr/local/etc/mediamtx.yml
sudo curl -K https://raw.githubusercontent.com/aerial-defence/ATAK-UAS-RTSP/main/mediamtx.yml -o /usr/local/etc/mediamtx.yml
sudo tee /etc/systemd/system/mediamtx.service >/dev/null << EOF
[Unit]
After=network.target
[Service]
ExecStart=/usr/local/bin/mediamtx /usr/local/etc/mediamtx.yml
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable mediamtx
Start mediamtx and tail syslog to see how things look
sudo systemctl start mediamtx && tail -f /var/log/syslog
Check that the service is running
systemctl status mediamtx.service
Jan 12 23:55:41 rtsp-atak rtsp-simple-server[17053]: 2022/01/12 23:55:41 INF [RTSP] [conn 192.168.86.60:52250] opened Jan 12 23:55:41 rtsp-atak rtsp-simple-server[17053]: 2022/01/12 23:55:41 INF [RTSP] [session 343057601] opened by 192.168.86.60:52250 Jan 12 23:55:41 rtsp-atak rtsp-simple-server[17053]: 2022/01/12 23:55:41 INF [RTSP] [session 343057601] is publishing to path 'live/ATAK', 1 track with TCP
rtsp://ipaddress:8554/live/ATAK
For AWS, I have the following ports forwarded
- Video Broadcast Destination: RTSP-Push (VMS systems)
- Video Destination IP Address: i.e. - 192.168.86.232
- Video Destination Port: 8554
- Use SSL: No
- Video Broadcast Identifier: live/ATAK
- Reliable P2P Connection (TCP): Yes
(The live/ATAK can be changed, but make sure to not put an ending slash)