I'm using ffmpeg combined with tee and mplayer to have a simple video livestream and recorder over SSH. Now, I'd love to embed the current (server) time in the stream. The format doesn't matter much, ideally would be YYYY-MM-DD HH:MM:SS.
I've found this how-to suggesting the following command:
ffmpeg -f video4linux2 -input_format mjpeg -s 1280x720 -i /dev/video0 \
-vf "drawtext=fontfile=/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf: \
text='%{localtime\:%T}': [email protected]: x=7: y=700" -vcodec libx264 \
-preset veryfast -f mp4 -pix_fmt yuv420p -y output.mp4
But using the -vf portion of this results in the following error for me:
[NULL @ 0x55e4ef96b2a0] Unable to find a suitable output format for 'text=%{localtime:%T}:'
text=%{localtime:%T}:: Invalid argument
I've also tried this command (the third code block in the Q), just to test it, but it failed aswell:
[Parsed_drawtext_0 @ 0x55fb2862a940] Both text and text file provided. Please provide only one
[AVFilterGraph @ 0x55fb28629fc0] Error initializing filter 'drawtext' with args 'text=%{pts:hms:1553359336.166336638}'
Finally, I also found this question, and tried it, slightly modified like this (this is showing my full command, I've only adjusted the -vf options in the past two examples):
ffmpeg -r 20 -s 640x480 -f video4linux2 -i /dev/video0 -vf "drawtext=fontsize=90:fontcolor=white: fontfile=/usr/share/fonts/TTF/DejaVuSans.ttf: text='%{localtime\:%X}'" -f avi -
This presents me with the following error:
[NULL @ 0x55ae61d051a0] Unable to find a suitable output format for 'fontfile=/usr/share/fonts/TTF/DejaVuSans.ttf:'
fontfile=/usr/share/fonts/TTF/DejaVuSans.ttf:: Invalid argument
Modifying what I've found here a bit to:
-vf drawtext="fontfile='/usr/share/fonts/cantarell/Cantarell-Light.otf':fontsize=14:fontcolor=white:shadowcolor=black:shadowx=2:shadowy=1:text='%H-%M-%S':x=8:y=8"
Presents me with:
[Parsed_drawtext_0 @ 0x55e36db2aa40] Stray % near 'H-%M-%S'
Note that using this comment with just text (e.g. text='test') works fine..
Adding 1-4 \s in front of the %s shows no change in error or effect.
My ffmpeg version: ffmpeg version 3.2.12-1~deb9u1 on a debian machine.
It has been compiled with the drawtext library and it is present in ffmpeg -filters.
