I'm trying to make an RTMP stream of a video and put some graphical data on it. I have a command which creates the output I need. The only problem is that despite of the fact the PNG image is being updated on disk during the render process, in output video the overlay stays always the same. I would like ffmpeg to take a PNG image from disk every time it has been changed (or once a minute or so) and use it as an overlay. Is that possible?
Here is the command I use to render the output:
ffmpeg \
-re -y \
-f lavfi \
-i "movie=filename=video/videobg.mp4:loop=0, setpts=N/(FRAME_RATE*TB)" \
-loop 1 \
-i images/forecast.png \
-filter_complex "[1:v]format=argb,geq=r='r(X,Y)':a='0.9*alpha(X,Y)'[overlay]; [0:v][overlay]overlay" \
-i data/musicbg.mp3 \
-ac 1 \
-ar 44100 \
-b:a 128k \
-vcodec libx264 \
-pix_fmt yuv420p \
-r 30 \
-g 60 \
output.mp4
Well, I have finally figured out how to make what I want. Hope, this could be useful for someone else.
The only thing I had to do is to add a -f image2
option for the image input. The command differs a bit from the one I posted above, because I changed the order of input sources, but in fact it is the same.
Here is the solution:
ffmpeg \
-re -y \
-loop 1 \
-f image2 \
-i images/forecast.png \
-f lavfi \
-i "movie=filename=video/videobg.mp4:loop=0, setpts=N/(FRAME_RATE*TB)" \
-filter_complex "[0:v]format=argb,geq=r='r(X,Y)':a='0.9*alpha(X,Y)'[overlay]; [1:v][overlay]overlay" \
-i data/musicbg.mp3 \
-ac 1 \
-ar 44100 \
-b:a 128k \
-vcodec libx264 \
-pix_fmt yuv420p \
-r 30 \
-g 60 \
output.mp4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With