Skip to main content
Open in Kaggle  Open in Colab  Download Notebook
This documentation page is also available as an interactive notebook. You can launch the notebook in Kaggle or Colab, or download it for use with an IDE or local Jupyter installation, by clicking one of the above links.
Burn text, captions, or watermarks directly into video files.

Problem

You need to add text to videos—captions, watermarks, titles, or dynamic labels. Manual video editing doesn’t scale for batch processing.

Solution

What’s in this recipe:
  • Add simple text overlays
  • Create styled captions with backgrounds
  • Position text with alignment options
  • Crop a rectangular region from a video
Use video.overlay_text() to burn text into videos with full control over styling and position, and video.crop() to extract a rectangular region.

Setup

Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘overlay_demo’.
<pixeltable.catalog.dir.Dir at 0x17e873990>

Load sample videos

Created table ‘videos’.
Inserted 1 row with 0 errors in 3.21 s (0.31 rows/s)
1 row inserted.

Add a simple text overlay

Added 1 column value with 0 errors in 1.25 s (0.80 rows/s)
1 row updated.

Add YouTube-style captions

Added 1 column value with 0 errors in 1.08 s (0.92 rows/s)
1 row updated.

Add dynamic titles from table columns

Added 1 column value with 0 errors in 1.15 s (0.87 rows/s)
1 row updated.

Crop a region from a video

Use video.crop() to extract a rectangular region from a video. This is useful for focusing on a specific area of interest, removing borders, or preparing clips for object-specific analysis.
Added 1 column value with 0 errors in 0.56 s (1.78 rows/s)
1 row updated.

Explanation

Positioning options:
Styling options:
Background box options:
Requirements:
  • FFmpeg must be installed and in PATH

See also

Last modified on June 24, 2026