How to Print Unix Epoch Timestamp on Video with FFmpeg

This article explains how to overlay a running Unix epoch timestamp onto each frame of a video using FFmpeg. You will learn how to burn either the real-time system clock (wallclock time) or a calculated epoch timestamp relative to the video’s start time directly into the video track using the drawtext video filter.


Method 1: Print Real-Time System Epoch (Wallclock Time)

If you are capturing a live stream or want to print the exact time the video is being processed by your system, you can use the localtime or gmtime functions inside the drawtext filter.

Use the following command to burn the current Unix epoch timestamp (in seconds) onto the video:

ffmpeg -i input.mp4 -vf "drawtext=fontfile=/path/to/font.ttf:text='%{localtime\:%s}':x=10:y=10:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5" -codec:a copy output.mp4

How it works:


Method 2: Print Relative Epoch (Starting from a Specific Date/Time)

If you are processing a pre-recorded video and want the timestamp to start from a specific Unix epoch representing when the video was recorded, you should use mathematical evaluation based on the video’s timestamp (t).

Use this command to define a custom starting epoch:

ffmpeg -i input.mp4 -vf "drawtext=fontfile=/path/to/font.ttf:text='%{eif\:1700000000+t\:d}':x=10:y=10:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5" -codec:a copy output.mp4

How it works:


Adding Milliseconds to the Epoch Timestamp

If you need high-precision timestamps that include milliseconds, you can combine the relative time calculation with decimal formatting:

ffmpeg -i input.mp4 -vf "drawtext=fontfile=/path/to/font.ttf:text='%{eif\:1700000000+t\:d}.%{eif\:(t-floor(t))*1000\:d\:3}':x=10:y=10:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5" -codec:a copy output.mp4

How it works: