Add Real-Time Timestamp to Video Using FFmpeg

This guide demonstrates how to overlay the current date and time onto a video stream in real-time using the powerful command-line tool, FFmpeg. You will learn the exact command-line syntax, how to format the dynamic timestamp, and how to customize its appearance on your video output.

To burn a real-time timestamp onto a video, you must use FFmpeg’s drawtext video filter. This filter allows you to render text dynamically using system fonts and time-expansion variables.

The Basic Command

Here is the standard command to overlay the current local date and time onto a video file:

ffmpeg -i input.mp4 -vf "drawtext=fontfile='/path/to/font.ttf':text='%{localtime\:%Y-%m-%d %H\\\\\:%M\\\\\:%S}':x=10:y=10:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5" -c:v libx264 -c:a copy output.mp4

Parameter Breakdown

Applying to Live Streams

If you are capturing a live camera stream or RTSP feed and want to burn the real-time clock onto the output stream, apply the filter in the same way during the transcoding step:

ffmpeg -rtsp_transport tcp -i rtsp://your_stream_url -vf "drawtext=fontfile='/path/to/font.ttf':text='%{localtime\:%Y-%m-%d %H\\\\\:%M\\\\\:%S}':x=w-tw-10:y=10:fontsize=20:fontcolor=yellow:box=1:boxcolor=black@0.4" -c:v libx264 -preset ultrafast -f flv rtmp://destination_url

Note: In this live-streaming example, x=w-tw-10 automatically positions the timestamp in the top-right corner (video width minus text width minus a 10-pixel margin).