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
%pip install -qU pixeltable
Load videos
import pixeltable as pxtimport pixeltable.functions as pxtf# Create a fresh directorypxt.drop_dir('thumbnail_demo', force=True)pxt.create_dir('thumbnail_demo')
Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘thumbnail_demo’.
<pixeltable.catalog.dir.Dir at 0x14d3a1990>
# Create table for videosvideos = pxt.create_table('thumbnail_demo/videos', {'video': pxt.Video})
Created table ‘videos’.
# Insert sample videos from public S3 buckets3_prefix = 's3://multimedia-commons/'video_paths = [ 'data/videos/mp4/ffe/ffb/ffeffbef41bbc269810b2a1a888de.mp4', 'data/videos/mp4/ffe/feb/ffefebb41485539f964760e6115fbc44.mp4',]videos.insert([{'video': s3_prefix + path} for path in video_paths])