Burn Local Timezone Timestamps onto Video with FFmpeg
Burning a highly accurate, localized timestamp onto a video is a
crucial requirement for security footage, dashcams, and event
recordings. Using FFmpeg’s powerful drawtext video filter,
you can overlay the current local system time, display specific timezone
abbreviations, or even synchronize a custom start time with the video’s
presentation timestamp (PTS). This guide will show you how to implement
these solutions using clear, production-ready FFmpeg commands.
Overlaying the System’s Local Time
To burn the current local time of the machine running the command,
use FFmpeg’s localtime function inside the
drawtext filter. The %Z format specifier is
used to display the local timezone abbreviation (e.g., EST, CET, or
UTC).
Run the following command:
ffmpeg -i input.mp4 -vf "drawtext=text='%{localtime\:%Y-%m-%d %H\\:%M\\:%S %Z}':x=10:y=10:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5" -c:a copy output.mp4How It Works:
text='%{localtime\:...}': Tells FFmpeg to fetch the local system time.%Y-%m-%d %H\\:%M\\:%S %Z: Formats the date and time. Note that colons must be escaped with double backslashes (\\:) so FFmpeg does not confuse them with filter delimiters.%Z: Dynamically prints the local timezone name based on your system configuration.x=10:y=10: Places the timestamp in the top-left corner.box=1:boxcolor=black@0.5: Adds a semi-transparent black background behind the text to ensure readability.
Specifying a Different Timezone
If you are running the command on a cloud server configured to UTC
but want the video to display a specific local timezone (such as
America/New_York or Europe/London), you can
temporarily set the TZ environment variable before running
the FFmpeg command.
On Linux and macOS:
TZ="America/New_York" ffmpeg -i input.mp4 -vf "drawtext=text='%{localtime\:%Y-%m-%d %H\\:%M\\:%S %Z}':x=10:y=10:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5" -c:a copy output.mp4On Windows (Command Prompt):
set TZ=America/New_York
ffmpeg -i input.mp4 -vf "drawtext=text='%%{localtime\:%%Y-%%m-%%d %%H\\:%%M\\:%%S %%Z}':x=10:y=10:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5" -c:a copy output.mp4(Note: In Windows Command Prompt, percent signs %
must be doubled %% to prevent the shell from parsing them
as variables).
On Windows (PowerShell):
$env:TZ="America/New_York"
ffmpeg -i input.mp4 -vf "drawtext=text='%{localtime\:%Y-%m-%d %H\\:%M\\:%S %Z}':x=10:y=10:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5" -c:a copy output.mp4Burning a Video Start Time Linked to the Timeline
If you want the timestamp to represent the actual time the video was
recorded rather than the time you are running the FFmpeg command, you
must use the pts parameter. This allows the clock to start
at a specific Unix epoch timestamp and increment progressively with the
video’s playback.
To do this, convert your local recording start time to a Unix epoch
timestamp (seconds since January 1, 1970). For example,
1706784000 represents
2024-02-01 11:00:00 UTC.
Use the following syntax:
ffmpeg -i input.mp4 -vf "drawtext=text='%{pts\:localtime\:1706784000\:%Y-%m-%d %H\\:%M\\:%S %Z}':x=10:y=10:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5" -c:a copy output.mp4Key Parameters:
pts: References the Presentation Time Stamp of the video frames.1706784000: The base epoch time from which the clock will begin counting.%Z: Will calculate and output the timezone offset corresponding to the host system or the configuredTZenvironment variable.