FFmpeg-based RTMP streaming container with GPU acceleration support for the MarchProxy Unified NLB Architecture.
- RTMP Protocol Support: Full RTMP server implementation
- FFmpeg Transcoding: Industry-standard video transcoding
- CPU Encoding: x264 (H.264) and x265 (H.265) software encoders
- GPU Acceleration:
- NVIDIA NVENC (H.264/H.265)
- AMD AMF (H.264/H.265)
- Adaptive Streaming:
- HLS (HTTP Live Streaming)
- DASH (Dynamic Adaptive Streaming over HTTP)
- Multi-Bitrate: Automatic adaptive bitrate ladder (1080p, 720p, 480p, 360p)
- gRPC Integration: ModuleService implementation for NLB communication
RTMP Input → RTMP Server → FFmpeg Transcoder → HLS/DASH Output
↓ ↓
Session Mgmt GPU Detection
↓ ↓
gRPC Server Encoder Selection
Three variants available:
-
CPU: Software encoding (x264/x265)
docker build -f Dockerfile -t marchproxy-rtmp:cpu . -
NVIDIA: Hardware encoding (NVENC)
docker build -f Dockerfile.nvidia -t marchproxy-rtmp:nvidia . -
AMD: Hardware encoding (AMF)
docker build -f Dockerfile.amd -t marchproxy-rtmp:amd .
docker run -d \
-p 1935:1935 \
-p 50053:50053 \
-v /path/to/streams:/var/lib/marchproxy/streams \
-e RTMP_ENCODER=x264 \
marchproxy-rtmp:cpudocker run -d \
--runtime=nvidia \
--gpus all \
-p 1935:1935 \
-p 50053:50053 \
-v /path/to/streams:/var/lib/marchproxy/streams \
-e RTMP_ENCODER=nvenc_h264 \
-e NVIDIA_VISIBLE_DEVICES=all \
-e NVIDIA_DRIVER_CAPABILITIES=compute,video,utility \
marchproxy-rtmp:nvidiadocker run -d \
--device=/dev/kfd \
--device=/dev/dri \
--group-add video \
--group-add render \
-p 1935:1935 \
-p 50053:50053 \
-v /path/to/streams:/var/lib/marchproxy/streams \
-e RTMP_ENCODER=amf_h264 \
marchproxy-rtmp:amd| Variable | Default | Description |
|---|---|---|
RTMP_HOST |
0.0.0.0 |
RTMP server host |
RTMP_PORT |
1935 |
RTMP server port |
RTMP_GRPC_PORT |
50053 |
gRPC server port |
RTMP_LOG_LEVEL |
info |
Log level (debug, info, warn, error) |
RTMP_ENCODER |
auto |
Video encoder (auto, x264, x265, nvenc_h264, nvenc_h265, amf_h264, amf_h265) |
RTMP_PRESET |
medium |
Encoding preset (ultrafast, fast, medium, slow) |
RTMP_OUTPUT_DIR |
/var/lib/marchproxy/streams |
Output directory for streams |
RTMP_ENABLE_HLS |
true |
Enable HLS output |
RTMP_ENABLE_DASH |
true |
Enable DASH output |
RTMP_SEGMENT_DURATION |
6 |
Segment duration in seconds |
RTMP_MAX_BITRATE |
10 |
Max bitrate in Mbps |
RTMP_MAX_STREAMS |
100 |
Max concurrent streams |
RTMP_MAX_RESOLUTION |
1080 |
Max resolution height |
Create /etc/marchproxy/rtmp.yaml:
host: 0.0.0.0
port: 1935
grpc-port: 50053
log-level: info
encoder: auto
preset: medium
output-dir: /var/lib/marchproxy/streams
enable-hls: true
enable-dash: true
segment-duration: 6
max-bitrate: 10
max-streams: 100
max-resolution: 1080
encoder-params:
tune: zerolatency
profile: highThe container automatically detects available GPUs and selects the best encoder:
- NVIDIA GPU detected →
nvenc_h264 - AMD GPU detected →
amf_h264 - No GPU →
x264(CPU)
Override with RTMP_ENCODER environment variable.
-
Settings → Stream
- Service: Custom
- Server:
rtmp://your-server:1935/live - Stream Key:
your_stream_key
-
Settings → Output
- Output Mode: Advanced
- Encoder: x264 (will be transcoded by container)
- Bitrate: 6000 Kbps
ffmpeg -re -i input.mp4 \
-c:v libx264 -preset veryfast -b:v 6000k \
-c:a aac -b:a 192k \
-f flv rtmp://your-server:1935/live/your_stream_keyhttp://your-server/streams/your_stream_key/master.m3u8
http://your-server/streams/your_stream_key/dash/manifest.mpd
- Single stream: ~2-3 CPU cores
- 1080p30: ~50-70% CPU on modern CPU
- Latency: 6-12 seconds
- Single stream: ~5-10% GPU, <5% CPU
- Can handle 10+ concurrent 1080p streams on RTX 3060
- Latency: 6-12 seconds
- Single stream: ~5-10% GPU, <5% CPU
- Can handle 8+ concurrent 1080p streams on RX 6600
- Latency: 6-12 seconds
Default ladder (configurable):
| Profile | Resolution | Bitrate | Audio |
|---|---|---|---|
| 1080p | 1920x1080 | 5000 Kbps | 192 Kbps |
| 720p | 1280x720 | 3000 Kbps | 128 Kbps |
| 480p | 854x480 | 1500 Kbps | 128 Kbps |
| 360p | 640x360 | 800 Kbps | 96 Kbps |
Implements ModuleService for NLB integration:
GetStatus()- Module status and statsGetRoutes()- Active streamsGetMetrics()- Transcoding metricsHealthCheck()- Health status
# CPU version
go build -o rtmp-proxy ./cmd/rtmp
# Run
./rtmp-proxy \
--host 0.0.0.0 \
--port 1935 \
--grpc-port 50053 \
--encoder auto \
--preset mediumLimited AGPL3 - See LICENSE file
- Documentation: https://docs.marchproxy.com
- Issues: https://github.com/penguintech/marchproxy/issues
- Website: https://www.penguintech.io