Q: ffmpeg drawtext “localtime” video filter - disp

2020-05-09 01:03发布

问题:

I'm having issues escaping ':' symbol and displaying localtime in a hms(HH:MM:SS) format for overlay over a Live input(MPEG-TS) which is then pushed out as Live output - I've fumbled my way to displaying 'localtime' in a format which achieves about half of what I'm trying to get to, the code sample of that is:

ffmpeg -re -hide_banner -i LIVE_INPUT -vf drawtext="fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%H %M %S}'" -f LIVE_OUTPUT

What it achieves is that it displays local time in a "HH MM SS" format instead of "HH:MM:SS"...


I did try escaping ':' by writing it like this:

ffmpeg -re -hide_banner -i LIVE_INPUT -vf drawtext="fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%H\\:%M\\:%S}'" -f LIVE_OUTPUT

and this:

ffmpeg -re -hide_banner -i LIVE_INPUT -vf drawtext="fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%H\:%M\:%S}'" -f LIVE_OUTPUT

as well as like this:

ffmpeg -re -hide_banner -i LIVE_INPUT -vf drawtext="fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%H \: %M \: %S}'" -f LIVE_OUTPUT

But none of the above helped as it returns different errors because ffmpeg tries to either parse '%H' '%M' and '%S' as multiple, separate arguments for localtime (localtime then complains that it can only accept x1 argument at most), or ffmpeg complains that there are loose '%' characters near "H" ... clearly I'm not escaping it correctly or my argument order is incorrect...

标签: ffmpeg