Media-over-QUIC is a streaming protocol built upon cutting edge protocols (QUIC, HTTP3) and browser APIs (WebTransport, WebCodecs). It's slightly faster than WebRTC, has an advanced data recovery mechanism (placed at the frame level and not at the packet level), it supports additional codecs (FLAC) and is less complicated to route.
2.0 KiB
2.0 KiB
FFmpeg
FFmpeg can publish a stream to the server by acting as a RTSP client, RTMP client, SRT client, WebRTC client or by sending MPEG-TS packets or RTP packets. The recommended way is acting as a RTSP client.
FFmpeg as a RTSP client
ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f rtsp rtsp://localhost:8554/mystream
The resulting stream will be available on path /mystream.
FFmpeg as a RTMP client
ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f flv rtmp://localhost:1935/mystream
FFmpeg and MPEG-TS over UDP
In MediaMTX configuration, add a path with source: udp+mpegts://238.0.0.1:1234. Then:
ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f mpegts 'udp://238.0.0.1:1234?pkt_size=1316'
FFmpeg and MPEG-TS over Unix socket
In MediaMTX configuration, add a path with source: unix+mpegts:///tmp/socket.sock. Then:
ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=30 \
-c:v libx264 -pix_fmt yuv420p -preset ultrafast -b:v 600k \
-f mpegts unix:/tmp/socket.sock
FFmpeg and RTP over UDP
In MediaMTX configuration, add a path with source: udp+rtp://238.0.0.1:1234 and a valid rtpSDP (read RTP). Then:
ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=30 \
-c:v libx264 -pix_fmt yuv420p -preset ultrafast -b:v 600k \
-f rtp udp://238.0.0.1:1234?pkt_size=1316
FFmpeg as a SRT client
ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f mpegts 'srt://localhost:8890?streamid=publish:stream&pkt_size=1316'
FFmpeg as a WebRTC client
ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=30 \
-f lavfi -i "sine=frequency=1000:sample_rate=48000" \
-c:v libx264 -pix_fmt yuv420p -preset ultrafast -b:v 600k \
-c:a libopus -ar 48000 -ac 2 -b:a 128k \
-f whip http://localhost:8889/stream/whip
WARNING: in case of FFmpeg 8.0, a video track and an audio track must both be present.