Minimal SRT Stream Example with ffmpeg

Viewed 9905

I'm having a hard finding a simple solution to showcase the srt streaming protocol with FFmpeg. The only article that I've found, is either going over multiple hoops to setup a stream. Is there no way to do a simple receiver/sender principle like in the old days with udp?

Sender:

ffmpeg  -i myfile.mp4 -vcodec libx264 -crf 12 -f mpegts udp://192.168.1.5:1234

Receiver:

ffplay udp://192.168.1.5:1234
2 Answers

Your ffmpeg needs to be compiled with --enable-libsrt to support the SRT protocol. See the output of ffmpeg -protocols to determine if it supports SRT.

Untested examples:

# stream copy
ffmpeg -re -i input.mp4 -c copy -f mpegts srt://192.168.1.5:1234

# re-encode
ffmpeg -re -i input.mp4 -c:v libx264 -b:v 4000k -maxrate 4000k -bufsize 8000k -g 50 -f mpegts srt://192.168.1.5:1234

See FFmpeg Protocols Documentation: SRT.

I also miss comprehensive documentation and explanation on how to use SRT. However here is a minimum example I use:

Sender which acts as a listener and waits for connections:

ffmpeg -i test.mp4 -c:v libx264 -f mpegts 'srt://:40052?mode=listener&latency=20000000'

Receiver which acts as a caller:

ffmpeg -i 'srt://192.168.1.345:40052?mode=caller' -c copy output.mkv
Related