A skill that extracts keyframes from video files and analyzes their content. Automatically removes duplicate frames and optimizes image quality to reduce token consumption. Use when: - User provides a video file (.mp4, .mov, .avi, etc.) - User requests "watch this video", "analyze this video", "what's in this video" - Checking screen recordings or screencasts - Keyframe extraction is needed from video
Extract keyframes from video, present token cost, then analyze.
Windows: ffmpeg must be available in a conda environment named media tools.
Linux/Mac: ffmpeg must be on PATH; Python deps via venv.
Clearly understand why the user wants the video analyzed:
This intent becomes important context for the analysis.
Detect the platform and run the appropriate setup:
Windows — conda media tools env:
conda install -n "media tools" pillow numpy --quiet -y
Linux/Mac — venv:
cd {baseDir}/scripts
python3 -m venv venv
source venv/bin/activate
pip install Pillow numpy --quiet
Windows (conda):
conda run -n "media tools" python "{baseDir}/scripts/extract_keyframes.py" "<video_path>" --method scene --ensure-last
Linux/Mac (venv):
source {baseDir}/scripts/venv/bin/activate
# Fast default (scene detection) with optional last-frame inclusion
python3 {baseDir}/scripts/extract_keyframes.py "<video_path>" --method scene --ensure-last
After user approval, run analyze_frames_mistral.py with all frame paths.
The script batches every 4 consecutive frames into one Mistral API call and
fires all batches in parallel (e.g. 40 frames → 10 simultaneous API calls).
Setup (first time only):
# Linux/Mac
source {baseDir}/scripts/venv/bin/activate
pip install mistralai --quiet
# Windows (conda)
conda install -n "media tools" mistralai --quiet -y
Run analysis:
# Linux/Mac
source {baseDir}/scripts/venv/bin/activate
python3 {baseDir}/scripts/analyze_frames_mistral.py \
frame_001.jpg frame_002.jpg ... frame_040.jpg \
--prompt "User intent: {Intent from Step 1}. Describe what is happening across these consecutive video frames." \
--format json \
--output analysis.json
# Windows (conda)
conda run -n "media tools" python "{baseDir}/scripts/analyze_frames_mistral.py" ^
frame_001.jpg frame_002.jpg ... frame_040.jpg ^
--prompt "User intent: {Intent from Step 1}. Describe what is happening across these consecutive video frames." ^
--format json ^
--output analysis.json
Key options:
--model — default mistral-large-latest (Mistral Large 3); use pixtral-large-latest or pixtral-12b-2409 for vision-only alternatives--workers N — cap parallel calls (default: all batches at once)--format json|text — JSON for structured pickup, text for readabilityMISTRAL_API_KEY — read from env or --api-key flagThe script reads the JSON output and you merge the results[].description fields
into a final chronological report.
Benefits of this approach:
mistral-large-latest sees exactly 4 consecutive frames per call for temporal contextmistralai SDK, no Claude subagents neededTip: Pass
--env /path/to/.env.localif your project storesMISTRAL_API_KEYin.env.localinstead of.env.
| Option | Default | Description |
|---|---|---|
-m, --method | scene | Extraction method: scene (fast) or similarity (slow) |
-t, --threshold | 0.3 | Scene threshold for scene method (lower = more frames kept) |
-q, --quality | 30 | JPEG quality (1-100) |
-s, --scale | 0.3 | Resize scale |
-o, --output | <video_name>_keyframes/ | Output directory |
-w, --workers | CPU-1 | Parallel compression workers (similarity method only) |
--ensure-last | off | Include last frame (scene method only) |
Windows (conda):
# More aggressive reduction
conda run -n "media tools" python "{baseDir}/scripts/extract_keyframes.py" video.mp4 --method scene -t 0.2 -q 20 -s 0.2 --ensure-last
# Similarity method
conda run -n "media tools" python "{baseDir}/scripts/extract_keyframes.py" video.mp4 --method similarity -t 0.85 -q 30 -s 0.3 -w 6
Linux/Mac (venv):
# More aggressive reduction (lower threshold, quality, and size)
python3 {baseDir}/scripts/extract_keyframes.py video.mp4 --method scene -t 0.2 -q 20 -s 0.2 --ensure-last
# Similarity method (slower, more precise)
python3 {baseDir}/scripts/extract_keyframes.py video.mp4 --method similarity -t 0.85 -q 30 -s 0.3 -w 6