From the source code of the drawtext
filter (from libavfilter/vf_drawtext.c
in the source tree), there appears to be a textfile
parameter which can specify a path to a file containing the string to draw (as opposed to setting the text
parameter as in your example). You may want to experiment with passing it a filepath as textfile
, and updating the file while viewing the video output.
You would also need another program/daemon running in parallel to update the file (which would just contain the current text to be displayed), but this program would be fairly trivial assuming you could synchronize it with the system clock.
Alternatively, you can modify the drawtext
filter itself to display a particular string based on the current timecode (which is available to FFmpeg filters). While this would require modifying the filter's source code and recompiling from scratch, it would also avoid the use of a separate program/daemon running in parallel (as your own code would be invoked whenever FFmpeg tries to draw a string).
However, assuming the textfile
parameter works (read: is updated every frame), that would probably be a better method, as a simple daemon to update the text file could be written in a scripting language like Python.