[FFmpeg-user] drawtext reload=N > 1?

Gyan Doshi ffmpeg at gyani.pro
Mon Feb 28 08:58:59 EET 2022



On 2022-02-28 10:37 am, Steven Kan wrote:
> I am overlaying real-time weather on streaming video:
>
> https://www.youtube.com/channel/UCIVY11504PcY2sy2qpRhiMg/live
>
> I have a script reading from openweather.org every 10 minutes and writing to weather.txt*, and then drawtext reads weather.txt and applies it via:
>
> ./ffmpeg -thread_queue_size 2048 -hwaccel videotoolbox -i 'rtsp://anonymous:password1@192.168.1.13:554' -hwaccel videotoolbox -i 'rtsp://anonymous:password1@192.168.1.45:554' -vcodec h264_videotoolbox -b:v 5000k -acodec copy -t 2:00:00 -filter_complex "hstack=inputs=2,fps=20[stacked];[stacked]drawtext='fontfile=/System/Library/Fonts/Helvetica.ttc: textfile=/tmp/weather.txt: fontcolor=white: fontsize=48: x=(w-text_w)*0.01: y=(h-text_h)*0.01:reload=600'" -f flv "rtmp://a.rtmp.youtube.com/live2/<my-youtube-streaming-key>”
>
> It’s working, but it seems very inefficient to read weather.txt every 1 frame when it gets updated only every 12,000 frames.
>
> According to the documentation, reload is a Boolean to read every frame or not, and attempting reload=2 or reload=600 results in:
>
> [drawtext @ 0x7fa696010600] Unable to parse option value "2" as boolean
>
> Would it be worthy feature request to allow drawtext to accept integer values N > 1, and then reload the text file every Nth frame? It seems like a win for CPU and I/O loading, with the benefit of being fully backward compatible with existing scripts that read in every 1 frame (e.g. reload=1).

This has come up before. I'll patch it to make it an interval.

Regards,
Gyan


More information about the ffmpeg-user mailing list