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.
Automatically create preview thumbnails from video files at specific
timestamps or intervals.
Problem
You have video files that need preview thumbnails for galleries, search
results, or video players. Manually extracting frames doesn’t scale.
Solution
What’s in this recipe:
- Extract thumbnail at a specific timestamp
- Generate multiple thumbnails per video
- Resize thumbnails to standard dimensions
You add computed columns that extract frames from videos. Thumbnails are
generated automatically when you insert new videos.
Setup
Load videos
Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘thumbnail_demo’.
<pixeltable.catalog.dir.Dir at 0x14d3a1990>
Created table ‘videos’.
Inserting rows into `videos`: 2 rows [00:00, 382.20 rows/s]
Inserted 2 rows with 0 errors.
2 rows inserted, 4 values computed.
Extract a single frame at a specific time (e.g., 1 second into the
video):
Added 2 column values with 0 errors.
2 rows updated, 2 values computed.
Resize thumbnails
Create standard-sized thumbnails for consistent display:
Added 2 column values with 0 errors.
2 rows updated, 2 values computed.
Multiple thumbnails with frame_iterator
For preview strips or timeline thumbnails, use frame_iterator to
extract multiple frames:
Inserting rows into `frames`: 17 rows [00:00, 9736.88 rows/s]
Explanation
Thumbnail extraction methods:
Common thumbnail sizes:
See also