How to Overlay Timecode on Video with FFmpeg

This article explains how to overlay a dynamic, real-time timecode onto a video using FFmpeg's powerful drawtext filter. You will learn the exact command-line syntax required to burn a highly visible timecode into your video, customize its position, set the frame rate, and adjust its visual appearance for professional video editing and review workflows.

To overlay a dynamic timecode, you must use the drawtext video filter in FFmpeg. This filter reads the video's framerate and generates an updating timecode display burned directly into the video frames.

The Basic Command

Here is the standard command to overlay a timecode at 30 frames per second (fps) in the center-bottom of your video:

ffmpeg -i input.mp4 -vf "drawtext=timecode='00\:00\:00\:00':r=30:x=(w-tw)/2:y=h-th-20:fontcolor=white:fontsize=24:box=1:boxcolor=black@0.5" -c:a copy output.mp4

Parameter Breakdown

Understanding how these parameters work allows you to customize the overlay to fit your specific needs:

  • timecode='00\:00\:00\:00': Sets the starting timecode in HH:MM:SS:FF (Hours:Minutes:Seconds:Frames) format. The colons must be escaped with backslashes (\:) so FFmpeg does not confuse them with filter parameter separators.
  • r=30: Specifies the frame rate of the timecode. This must match your input video's frame rate (e.g., 24, 29.97, 30, 60) for the timecode to remain accurate.
  • x=(w-tw)/2: Centers the text horizontally. w is the width of the video, and tw is the estimated width of the text.
  • y=h-th-20: Positions the text 20 pixels from the bottom of the video frame. h is the height of the video, and th is the estimated height of the text.
  • fontcolor=white: Sets the text color.
  • fontsize=24: Sets the size of the font in pixels.
  • box=1: Enables a background box behind the text to ensure readability against bright or busy video backgrounds.
  • boxcolor=black@0.5: Sets the background box color to black with a 50% opacity (transparency is defined by the value after the @ symbol).

Setting a Custom Font

By default, FFmpeg will use a system fallback font. If you want to use a specific font (such as Arial or Courier for monospaced numbers), you must specify the path to the font file:

ffmpeg -i input.mp4 -vf "drawtext=fontfile=/path/to/font.ttf:timecode='00\:00\:00\:00':r=23.976:x=(w-tw)/2:y=h-th-40:fontcolor=white:fontsize=32:box=1:boxcolor=black@0.6" -c:a copy output.mp4

Note: For Windows users, the font path might look like fontfile='C\:/Windows/Fonts/arial.ttf'.

Starting at a Specific Timecode

If your video starts at a specific hour or frame, you can adjust the starting value of the timecode parameter:

ffmpeg -i input.mp4 -vf "drawtext=timecode='01\:15\:30\:00':r=24:x=10:y=10:fontcolor=yellow:fontsize=20" -c:a copy output.mp4

This command starts the overlay timecode at 1 hour, 15 minutes, and 30 seconds, and places it in the top-left corner (x=10:y=10) with yellow text.