Adding a timestamp on frames captured using FFmpeg

1

I am trying to capture frames using FFmpeg and add current timestamp on to it.

Below code is working fine for a Linux PC :

ffmpeg -i  input -vf "drawtext=fontfile=/usr/share/fonts/TTF/Vera.ttf: text='%{localtime}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" image%03d.png

But same is not working for Windows because of:

  • The filter applied in the -vf option.
  • fontfile=/usr/share/fonts/TTF/Vera.ttf is not valid for Windows PC.
  • Some other things are also invalid.

I tried editing and removing it with some other option but nothing worked.

  1. I need to add time stamp on the images captured using FFmpeg in Windows.
  2. How could I add timestamp to it accurate to milliseconds - don't need a date in the timestamp.

What I have tried so far is:

text='%{localtime\:%X}%{pts\:hms}'

The above prints local time and the pts. I need to add both and print, so that I could get it exactly correct.

Any kind of help would be appreciated. I am cracking my head for this from last couple of hours.

video
ffmpeg
asked on Super User Dec 31, 2015 by csharpcoder • edited Feb 18, 2018 by Giacomo1968

2 Answers

3

I got it working. Just posting it here :

ffmpeg -i input -vf "drawtext=fontfile=/Windows/Fonts/Arial.ttf: text='%{localtime}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1: fontsize=30" -r 25 -t 5 image%03d.png
answered on Super User Dec 31, 2015 by csharpcoder • edited Feb 18, 2018 by Giacomo1968
0

Another approach that get's you timestamps with millisecond granularity is

ffmpeg -i input.mp4 -vf drawtext="fontsize=60:fontcolor=yellow:text='%{e\:t*1000}':x=(w-text_w):y=(h-text_h)" output.mp4

answered on Super User Dec 30, 2020 by bk138

User contributions licensed under CC BY-SA 3.0