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

Steven Kan steven at kan.org
Mon Feb 28 20:06:33 EET 2022



> On Feb 27, 2022, at 10:49 PM, Adam Nielsen via ffmpeg-user <ffmpeg-user at ffmpeg.org> wrote:
> 
>> 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).
>> 
>> Or are there downsides to this that I’m not seeing?
> 
> I thought about something similar as I'm also overlaying infrequently
> changed data (temperature) onto video.
> 
> However I ended up putting the file on a tmpfs partition so there's no
> actual disk IO, the whole thing sits in memory anyway.
> 
> Have you tried benchmarking to see how much benefit you'd get from this
> optimisation?  You could check CPU usage and I/O load with reload=1 and
> again with reload=0 and see what the difference is.  Let us know what
> you find, as I haven't actually tried this myself so it would be
> interesting to know what the impact is of reading the file on every
> frame.
> 
>> * and yes, I’m writing to weather.tmp and cping to weather.txt to
>> prevent a file I/O collision.
> 
> Do you mean "mv" instead of "cp"?  I don't think "cp" is atomic but
> "mv" is.  Using "cp" won't break anything but you might get a frame
> here or there with incomplete data.

Thanks for the tip about mv vs cp. I originally had mv, per the documentation, but then I changed it to cp during troubleshooting because I couldn’t figure out why my temp file kept disappearing, LOL. I’ve changed it back to mv.

Regarding I/O load, I know it’s probably negligible, but it just offends my sensibilities to read something 11,999 times for no reason. And if this feature gets implemented (thank you, Gyan!!!) then I won’t have to worry about where I put the tmp file. 


More information about the ffmpeg-user mailing list