ffmpeg filter to add timestamp on video

6,843

Solution 1

try this command:

ffmpeg -y -i input.mp4 -vf "drawtext=fontfile=roboto.ttf:fontsize=36:fontcolor=yellow:text='%{pts\:gmtime\:1575526882\:%A, %d, %B %Y %I\\\:%M\\\:%S %p}'" -preset ultrafast -f mp4 output.mp4

made changes in command as per your need.

also refer below links it will give you more idea about timestamp:

strftime - format date and time

Solution 2

I use the following filter:

-vf drawtext=fontfile=/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf:text='%{localtime}':[email protected]:x=7:y=7

I put this filter between the input specifications and the output specifications.

You just have to adapt:

  • x=XX and y=YY depending on the wished position.
  • fontfile= depending on the fonts available on your system.
Share:
6,843

Related videos on Youtube

Lea... FFmpeg
Author by

Lea... FFmpeg

Updated on September 18, 2022

Comments

  • Lea... FFmpeg
    Lea... FFmpeg over 1 year

    I have a problem displaying the timer on the video. I have consulted a few examples, but it does not show success. Help me fix it.

    enter image description here

    • Elisa Cha Cha
      Elisa Cha Cha over 4 years
      Copy and paste your ffmpeg command into your question so we can try it ourselves.
    • Lea... FFmpeg
      Lea... FFmpeg over 4 years
      You can see the image I have attached to the above
    • Elisa Cha Cha
      Elisa Cha Cha over 4 years
      Yes, but I could not copy and paste your command to easily debug it, and there are too many other questions to answer for me to look at the image and re-type it.
  • Lea... FFmpeg
    Lea... FFmpeg over 4 years
    I tried but having trouble displaying. they don't show the time, they are just characters.
  • John Smith
    John Smith over 3 years
    Thanks, this worked perfectly for me on the first try. I removed the "fontfile=/...ttf" part completely and it used a default font. Adding :fontsize=24 before :fontcolor made it bigger, too.