Documentation Index
Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
Use this file to discover all available pages before exploring further.
Problem
You have video files and need to extract frames for:- Object detection on video content
- Creating thumbnails or previews
- Building training datasets
- Scene analysis and classification
Solution
What’s in this recipe:- Extract frames at a fixed rate (FPS)
- Extract a specific number of frames
- Extract only keyframes for efficiency
frame_iterator that automatically extracts
frames from each video. New videos are processed without extra code.
Setup
Load videos
Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘video_demo’.
<pixeltable.catalog.dir.Dir at 0x1695d2650>
Created table ‘videos’.
Inserting rows into `videos`: 1 rows [00:00, 212.90 rows/s]
Inserted 1 row with 0 errors.
1 row inserted, 2 values computed.
Extract frames at fixed rate
Create a view that extracts 1 frame per second:Inserting rows into `frames`: 19 rows [00:00, 8687.65 rows/s]
Extract keyframes only
For faster processing, extract only keyframes (I-frames):Inserting rows into `keyframes`: 7 rows [00:00, 3277.53 rows/s]
Explanation
Extraction options: Only one offps, num_frames, or keyframes_only can be specified.
When to use keyframes:
- Quick video scanning and thumbnails
- Initial content classification
- Processing very long videos
frame: The extracted imagepos: Frame position in the videopts: Presentation timestamp