1

My point is to create a continuous video stream with overlay that will change depending on external events. Like YouTube radio channels, where the song name is changing depends on which track is currently playing.

I saw one of the interesting ways with using several ffmpeg instances and local streams for audio and video: one ffmpeg is playing audio to local port, and other combining it with video, taking the audio source from local audio stream. So I can change the audio during the stream without restarting it.

My question is, can I use the same scene for changing the overlay. Let's say I need to change the song name on the screen, is there any ways to do so with ffmpeg?

3
  • You might also want to look at avisynth+ avs-plus.net
    – stib
    Commented Feb 3, 2020 at 23:33
  • I'd suggest taking a look at "streamlabs" or "obs", which are made specifically for those instances. Commented Feb 4, 2020 at 13:36
  • Thanks, Florian! But I'm using headless server, and OBS needs access to the GPU. It does not work even over VNC with installed linux GUI like Gnome or KDE. So i need to use only software that does not uses GPU for streaming. Commented Feb 4, 2020 at 16:40

2 Answers 2

2

drawtext filter

If you just want to update some text on the screen the easiest method is to use the drawtext filter with the textfile and reload options.

ffmpeg -i input -vf "drawtext=textfile=songs.txt:reload=1" output

songs.txt will be reloaded once per frame. Be sure to update it atomically, or it may be read partially, or even fail.

overlay filter

If you prefer an image instead of text you have to manually select the image demuxer, loop the image, and replace overlay.png atomically whenever you want it to be updated.

ffmpeg -i input -f image2 -loop 1 -i overlay.png -filter_complex overlay output
1
  • Thanks a lot! This is exactly what I was looking for. Commented Feb 5, 2020 at 12:09
0

A slightly better solution in terms of CPU usage is to use -stream_loop -1 instead of -loop 1 and define a lower framerate (-framerate 1 to read the image once a second):

ffmpeg -i input -f image2 -stream_loop -1 -framerate 1 -i overlay.png -filter_complex overlay output

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.