Stream Anything,
Everywhere
MediaMTX is a ready-to-use streaming server that converts between protocols, making any camera or video source available to any viewer โ no coding required.
Supported Protocols
MediaMTX acts as a universal translator between streaming protocols. Here's what it supports:
WebRTC
Ultra-low latency peer-to-peer streaming. Ideal for live interactions, video calls, and real-time control.
Real-timeRTSP / RTP
The industry standard for IP cameras. Ingest streams from virtually any network camera or encoder.
IngestHLS
HTTP Live Streaming for broad compatibility. Works everywhere โ browsers, mobile apps, smart TVs.
AdaptiveWHIP / WHEP
WebRTC ingestion made simple. One-line setup for pushing streams from encoders or browsers.
IngestRTMP / RTMPS
Legacy but widely supported. Ingest from OBS, FFmpeg, and other RTMP encoders.
IngestWebSocket
Push frames over WebSocket for custom player implementations and low-level integrations.
Real-timeHow It Works
MediaMTX sits between your video sources and your viewers, handling protocol translation automatically.
Camera / Source
RTSP, RTMP, WHIPMediaMTX
Protocol ConversionViewers
WebRTC, HLS, WebSocketZero Configuration
MediaMTX auto-detects streams and exposes them via all supported protocols. Point your camera, start the server, share the URL.
WebRTC Streaming
WebRTC delivers sub-second latency for real-time interactive streaming. Perfect for live sports, gaming, IoT dashboards, and anything requiring instant feedback.
Sub-500ms Latency
Real-time video delivery without the delay of traditional HLS/DASH.
Encrypted by Default
DTLS/SRTP encryption built into the protocol. No extra configuration.
Firewall Friendly
Uses standard HTTPS/WebSocket ports. No complex NAT traversal needed.
Play a WebRTC Stream
// WebRTC player for browser
const pc = new RTCPeerConnection({
iceServers: [{ urls: 'stun:stun.l.google.com:19302' }]
});
pc.ontrack = (event) => {
const video = document.createElement('video');
video.srcObject = event.streams[0];
video.autoplay = true;
document.body.appendChild(video);
};
// Request offer from MediaMTX
const resp = await fetch('http://your-mediamtx:8889/webrtc', {
method: 'POST',
body: JSON.stringify({ apiKey: 'your-api-key', streamURL: 'rtsp://source/cam1' })
});
const { sdp, type } = await resp.json();
await pc.setRemoteDescription({ sdp, type });
await pc.setLocalDescription(await
pc.createAnswer());
# Push RTSP camera to MediaMTX via WebRTC
ffmpeg -rtsp_transport tcp -i "rtsp://camera-ip:554/stream" \
-c:v libx264 -preset ultrafast -tune zerolatency \
-fopus rtp://127.0.0.1:9000
# Or use WHIP for simpler ingestion
ffmpeg -re -stream_loop -1 -i video.mp4 \
-c:v libvpx -vp9 -tune:v zerolatency \
-f webm -headers "X-API-Key: your-key" \
http://mediamtx:8889/whip/cam1
Browser Limitations
WebRTC requires HTTPS in production. MediaMTX's built-in self-signed certs work for local testing only. Use a valid certificate or reverse proxy for production.
HLS Streaming
HLS (HTTP Live Streaming) packages video into small segments, enabling adaptive bitrate and seamless buffering. It's the most compatible streaming format available.
| Feature | HLS | WebRTC |
|---|---|---|
| Latency | 5โ30 seconds | <0.5 seconds |
| Compatibility | Universal (all browsers, mobile, TV) | Modern browsers only |
| Scalability | CDN-friendly, scales easily | Requires TURN for scale |
| Use Case | VOD, live events, broadcasts | Real-time, interactive |
HLS URLs from MediaMTX
# Base URL pattern
http://mediamtx:8889/hls/{stream-name}/index.m3u8
# Example โ full URLs
http://mediamtx:8889/hls/camera1/index.m3u8
http://mediamtx:8889/hls/front-door/index.m3u8
http://mediamtx:8889/hls/parking-lot/index.m3u8
Video.js Player Example
<!-- Include Video.js -->
<link href="https://unpkg.com/video.js@7/dist/video-js.min.css" rel="stylesheet" />
<script src="https://unpkg.com/video.js@7/dist/video.min.js"></script>
<div class="video-container">
<video id="my-stream" class="video-js vjs-big-play-centered" controls preload="auto" width="1280" height="720">
<source src="http://mediamtx:8889/hls/camera1/index.m3u8" type="application/x-mpegURL" />
</video>
</div>
<script>
const player = videojs('my-stream');
player.ready(() => console.log('HLS stream ready'));
</script>
Segment Duration
Default segment duration is 2 seconds. Lower values reduce latency but increase server load and the risk of
stuttering on slow connections. Tune via MediaMTX config: hlssegmentDuration.
RTSP Ingest
Real Time Streaming Protocol is the gold standard for IP cameras and professional broadcast equipment. MediaMTX ingests RTSP streams and exposes them to all other protocols.
# Full pipeline: RTSP source โ WebRTC + HLS + recording
ffmpeg -rtsp_transport tcp -i "rtsp://192.168.1.100:554/main" \
# Output 1: WebM via WebSocket
-c:v libvpx -vp9 -b:v 2M -f webm tcp://127.0.0.1:9000 \
# Output 2: HLS segments
-c:v libx264 -preset fast -tune zerolatency -b:v 2M -f hls \
-hls_time 2 -hls_list_size 5 -hls_segment_filename /tmp/seg_%03d.ts \
http://mediamtx:8889/hls/camera1/index.m3u8
Common RTSP URLs
Most cameras use these URL patterns: rtsp://ip:554/stream1,
rtsp://ip:554/live/stream1, or rtsp://ip:554/h264. Check your camera's
documentation.
Complete Examples
Copy-paste ready examples for common streaming scenarios.
# In OBS Studio:
# 1. Go to File โ Settings โ Stream
# 2. Select service: "Custom..."
# 3. Server: rtmp://your-mediamtx:1935/app
# 4. Stream key: my-stream
# View via HLS:
http://your-mediamtx:8889/hls/my-stream/index.m3u8
# View via WebRTC:
webrtc://your-mediamtx:8889/webrtc/my-stream
# 1. Transcode RTSP to WebRTC + HLS simultaneously
ffmpeg -rtsp_transport tcp -i "rtsp://camera-ip/stream" \
-c:v copy -c:a aac -b:a 128k \
-f rtsp rtsp://mediamtx:8554/mystream
# 2. Serve both HLS and WebRTC from same source
# MediaMTX config (yaml):
# paths:
# "*":
# source: rtsp://127.0.0.1:8554/mystream
# Access:
http://mediamtx:8889/hls/mystream/index.m3u8
webrtc://mediamtx:8889/webrtc/mystream
# MediaMTX handles all paths automatically
# Each unique path becomes a separate stream
# Camera 1 โ front door
ffmpeg -rtsp_transport tcp -i "rtsp://192.168.1.10/stream" -c:v copy -f rtsp
rtsp://mediamtx:8554/front-door
# Camera 2 โ parking lot
ffmpeg -rtsp_transport tcp -i "rtsp://192.168.1.11/stream" -c:v copy -f rtsp
rtsp://mediamtx:8554/parking-lot
# Access streams:
http://mediamtx:8889/hls/front-door/index.m3u8
http://mediamtx:8889/hls/parking-lot/index.m3u8
Quick Reference
Port mappings and stream URLs at a glance.
| Protocol | Port | URL Pattern | Use |
|---|---|---|---|
| WebRTC | 8889 | /webrtc/{stream} |
Low-latency browser playback |
| HLS | 8889 | /hls/{stream}/index.m3u8 |
Universal browser playback |
| RTMP ingest | 1935 | rtmp://server/app/{stream} |
OBS, FFmpeg ingestion |
| RTSP ingest | 8554 | rtsp://server/{stream} |
IP cameras, encoders |
| WebSocket | 8889 | /ws/{stream} |
Custom players, raw frames |
| WHIP | 8889 | /whip/{stream} |
WebRTC encoder ingestion |