0

I have a stream (rtmp) and I would like to generate some subtitles for it(based on what's happened on stream). I can generate it like a pipe, or some other way. I use script like this:

for i in $(seq -f "%02g" 0 20); do echo "
00:00:$i,000 --> 00:00:$i,999
caption $i
"; sleep 1; done | ffmpeg -nostdin \
-i "rtmp://domain.com/streamName live=1" \
-f srt -re -i - \
-c copy \
-c:s text \
-flush_packets 1 -f flv rtmp://output

the first part of a script is create a pipe with actually subs, pipe it to ffmpeg, and ffmpeg should merge subs with the stream. The point is that ffmpeg starts generating output only after the pipe is closed, and subtitles generation is ended. Is it possible to force ffmpeg start generation of output as soon as first lines in pipe appears?

  • Works here when I pipe an existing SRT file. – Gyan Aug 29 '19 at 14:41
  • @Gyan because existing SRT could be read to the end, while I actually need to generate it on the fly – Vitaliy Lozoviy Aug 29 '19 at 16:31
  • With -re flag, ffmpeg reads the input in real time - it delays reading the next packet until time elapsed is equal to media timestamp – Gyan Aug 29 '19 at 17:17
  • @Gyan without -re it still wait until srt EOF before output starts. The difference is that with -re output is thrown like a realtime stream, while without it - all at once, – Vitaliy Lozoviy Aug 30 '19 at 5:55
  • Did you ever figure this out? Need to do this as well – Beefy_Swain Apr 10 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.