2

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.

2
  • Can you post full command that you last tried with its console output? I was able to do it in Windows, with the same text expression and with a valid path to a font file.
    – Gyan
    Dec 31 '15 at 11:08
  • Ya thanks . . I figured it out . only thing i was mistaking is valid path to the font file . But now i need the timestamp correct to milliseconds . will post my working code..
    – coder3521
    Dec 31 '15 at 11:22
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
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.