In my live streaming scenario I need to grab a video source and inject subtitles that I generate algorithmically during the stream (i.e. I do not know the subtitles upfront), and publish the streams together.

From what documentation and examples I found -f srt input is always from a file, not a stream, or the subtitles already arrive inside a container stream.

To test, a naive approach of mine was to send UDP packets like this one:

00:00:05,000 --> 00:00:06,999
Hello World

and consume them as follows

ffmpeg -f srt -i udp://localhost:1233 \
-c:s mov_text out.mp4

This does not work which may be obvious to all folks familiar with FFmpeg. I am having a hard time identifying why this does not work or how else to approach the problem, probably because this is not a usual use case?

1 Answer 1


You can transform the stream to hls, then you can add the subtitle to every fragment. Make sure that the subtitle and the stream are in sync. After adding the subtitles you can move the new m3u8 file and fragments to be served by nginx. This will add few seconds of latency to your stream ( depending on the fragment duration and fragment count )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.