Update PNG overlay on video with ffmpeg

ぐ巨炮叔叔 提交于 2020-01-11 05:33:12

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/41132358/update-png-overlay-on-video-with-ffmpeg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!