Files
rtsp-simple-server/docs/2-publish/15-ffmpeg.md
T
eh f98c9c59ca rtsp: support unwrapping MPEG-TS tracks (#5476)
this allows to use MPEG-TS tracks with other protocols and with the recording system.

---------

Co-authored-by: aler9 <46489434+aler9@users.noreply.github.com>
2026-03-17 19:14:04 +01:00

1.7 KiB

FFmpeg

FFmpeg can publish a stream to the server in several ways. The recommended one consists in publishing with RTSP.

FFmpeg and RTSP

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 and RTMP

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 and SRT

ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f mpegts 'srt://localhost:8890?streamid=publish:stream&pkt_size=1316'

FFmpeg and WebRTC

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.