created mediamtx server for audio streams

This commit is contained in:
tdv
2025-09-23 19:01:48 +03:00
parent aa60651610
commit 4c4d254852
3 changed files with 114 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ services:
- snoopBack - snoopBack
snoop-api: snoop-api:
restart: unless-stopped
build: build:
context: ./server context: ./server
dockerfile: Dockerfile dockerfile: Dockerfile
@@ -61,6 +62,7 @@ services:
VAULT_TOKEN: "root" VAULT_TOKEN: "root"
VAULT_KV_PATH: "kv/data/snoop" VAULT_KV_PATH: "kv/data/snoop"
MINIO_ENDPOINT: "http://minio:9000" MINIO_ENDPOINT: "http://minio:9000"
JWT_SECRET: ${JWT_SECRET}
env_file: env_file:
- .env - .env
depends_on: depends_on:
@@ -75,6 +77,7 @@ services:
web: web:
restart: unless-stopped
build: build:
context: ./management-ui context: ./management-ui
dockerfile: Dockerfile dockerfile: Dockerfile
@@ -95,12 +98,47 @@ services:
networks: networks:
- proxy - proxy
mediamtx:
image: bluenviron/mediamtx:latest
# restart: unless-stopped
# Expose default listeners for all common protocols
ports:
- "8554:8554" # RTSP
- "1935:1935" # RTMP
- "8888:8888" # HLS / LL-HLS (HTTP)
- "8889:8889" # WebRTC HTTP (WHIP/WHEP/pages)
- "8189:8189/udp" # WebRTC ICE UDP
- "8890:8890/udp" # SRT
- "9997:9997" # Control API (enabled in config below; map if you want to access from host)
volumes:
- ./mediamtx/mediamtx.yml:/mediamtx.yml:ro,Z
- mediamtx-recordings:/recordings
networks:
- proxy
- snoopBack
rclone:
image: rclone/rclone:latest
command: rcd --rc-addr=:5572 --rc-no-auth
environment:
RCLONE_CONFIG_MINIO_TYPE: s3
RCLONE_CONFIG_MINIO_PROVIDER: Minio
RCLONE_CONFIG_MINIO_ENDPOINT: http://minio:9000
RCLONE_CONFIG_MINIO_ACCESS_KEY_ID: minioadmin
RCLONE_CONFIG_MINIO_SECRET_ACCESS_KEY: minioadmin
RCLONE_CONFIG_MINIO_REGION: us-east-1
RCLONE_CONFIG_MINIO_FORCE_PATH_STYLE: "true"
volumes:
- mediamtx-recordings:/recordings
networks:
- snoopBack
- proxy
volumes: volumes:
pgdata: pgdata:
miniodata: miniodata:
vault-data: vault-data:
mediamtx-recordings:
networks: networks:
proxy: proxy:

63
mediamtx/mediamtx.yml Normal file
View File

@@ -0,0 +1,63 @@
logLevel: info
# Enable Control API (useful for debugging; bound to localhost by default)
api: yes
apiAddress: :9997
# RTSP / RTMP / HLS
rtsp: yes
rtspAddress: :8554
rtmp: yes
rtmpAddress: :1935
hls: yes
hlsAddress: :8888
hlsVariant: lowLatency
# WebRTC (browser-friendly)
webrtc: yes
webrtcAddress: :8889
webrtcLocalUDPAddress: :8189
# Optional: add a STUN server if behind NAT
# webrtcICEServers2:
# - url: stun:stun.l.google.com:19302
# SRT (for resilient ingest)
srt: yes
srtAddress: :8890
authMethod: http
authHTTPAddress: http://snoop-api:8080/mediamtx/auth
# Recording (optional)
pathDefaults:
# record settings (per concurrent path/stream)
record: yes
recordFormat: fmp4
recordPath: /recordings/%path/%Y-%m-%d_%H-%M-%S-%f
recordSegmentDuration: 10m
recordDeleteAfter: 7d
# upload each completed segment to MinIO under:
# livestream/<device-guid>/<filename>
# runOnRecordSegmentComplete: >
# sh -c 'd="$(dirname "$MTX_SEGMENT_PATH")";
# f="$(basename "$MTX_SEGMENT_PATH")";
# curl -s -H "Content-Type: application/json"
# -X POST "http://rclone:5572/operations/copyfile?_async=true"
# -d "{\"srcFs\":\"$d\",\"srcRemote\":\"$f\",
# \"dstFs\":\"minio:livestream\",
# \"dstRemote\":\"$MTX_PATH/$f\"}"'
runOnRecordSegmentCreate: >
sh -c 'd="$(dirname "$MTX_SEGMENT_PATH")";
f="$(basename "$MTX_SEGMENT_PATH")";
curl -s -H "Content-Type: application/json"
-X POST "http://rclone:5572/operations/copyfile?_async=true"
-d "{\"srcFs\":\"$d\",\"srcRemote\":\"$f\",
\"dstFs\":\"minio:livestream\",
\"dstRemote\":\"$MTX_PATH/$f\"}"'
# Allow all paths by default
paths:
all:
source: publisher

View File

@@ -40,4 +40,17 @@ server {
proxy_read_timeout 3600s; proxy_read_timeout 3600s;
proxy_send_timeout 3600s; proxy_send_timeout 3600s;
} }
# --- LIVE ---
# HLS playlist/segments
location /hls/ {
proxy_pass http://mediamtx:8888/;
proxy_http_version 1.1;
}
# WebRTC WHIP/WHEP/test pages
location /webrtc/ {
proxy_pass http://mediamtx:8889/;
proxy_http_version 1.1;
}
} }