| name | video-extract |
| description | Extract frames, clips, and audio from video files using ffmpeg. Convert between formats, trim segments, create thumbnails, extract subtitles, and batch process. Use when user says "extract frames from video", "clip this segment", "convert to mp4", "get audio from video", "create thumbnail", or any video processing task.
|
| allowed-tools | ["Bash","Read","Write"] |
| model | haiku |
| user-invocable | true |
| when_to_use | When user needs to process a video file: extract frames/clips/audio, convert formats, trim/cut, get a thumbnail, or batch process videos. Triggers on: extract frames, clip video, convert video, trim, get audio from video, thumbnail, ffmpeg tasks.
|
| argument-hint | <frames|clip|audio|convert|thumbnail|info> <input-file> [options] |
Video Extract
Process video files with ffmpeg: extract frames, clips, audio, and more.
Prerequisites
Install ffmpeg:
brew install ffmpeg
Verify: ffmpeg -version
Commands
Video Info
ffprobe -v quiet -print_format json -show_format -show_streams input.mp4
ffprobe -v error -show_entries format=duration,size,bit_rate \
-show_entries stream=codec_name,width,height,r_frame_rate input.mp4
Extract Frames
ffmpeg -y -i input.mp4 -ss 00:01:30 -vframes 1 frame.jpg
ffmpeg -y -i input.mp4 -vf fps=1/5 frames/frame_%04d.jpg
ffmpeg -y -i input.mp4 frames/frame_%04d.png
Extract / Trim Clip
ffmpeg -y -ss 00:00:30 -i input.mp4 -t 00:00:15 -c copy clip.mp4
ffmpeg -y -ss 00:01:00 -to 00:02:30 -i input.mp4 -c copy clip.mp4
ffmpeg -y -i input.mp4 -ss 00:00:30 -t 00:00:15 clip.mp4
Extract Audio
ffmpeg -y -i input.mp4 -vn -acodec mp3 -q:a 2 audio.mp3
ffmpeg -y -i input.mp4 -vn -acodec aac -b:a 192k audio.aac
ffmpeg -y -i input.mp4 -vn audio.wav
Format Conversion
ffmpeg -y -i input.mov -c:v libx264 -c:a aac -crf 23 output.mp4
ffmpeg -y -i input.mp4 -c:v libvpx-vp9 -c:a libopus output.webm
ffmpeg -y -i input.mp4 -vf "fps=10,scale=640:-1" output.gif
ffmpeg -y -i input.mp4 -vcodec libx264 -crf 28 compressed.mp4
Create Thumbnail
ffmpeg -y -i input.mp4 -ss 00:00:05 -vframes 1 -vf scale=640:-1 thumb.jpg
ffmpeg -y -i input.mp4 -vf "thumbnail,scale=640:-1" -frames:v 1 thumb.jpg
Subtitles
ffmpeg -y -i input.mkv -map 0:s:0 subtitles.srt
ffmpeg -y -i input.mp4 -vf subtitles=subtitles.srt output_with_subs.mp4
Usage Examples
"Extract a frame every 10 seconds from lecture.mp4"
mkdir -p frames
ffmpeg -y -i lecture.mp4 -vf fps=1/10 frames/frame_%04d.jpg
echo "Frames saved to ./frames/"
"Cut from 2:30 to 5:00 in video.mp4"
ffmpeg -y -ss 00:02:30 -to 00:05:00 -i video.mp4 -c copy clip_2m30s_to_5m.mp4
"Get the audio from interview.mp4 as MP3"
ffmpeg -y -i interview.mp4 -vn -acodec mp3 -q:a 2 interview_audio.mp3
"Convert recording.mov to mp4"
ffmpeg -y -i recording.mov -c:v libx264 -c:a aac -crf 23 recording.mp4
Rules
- Check if ffmpeg is installed first:
which ffmpeg
- If not installed, show
brew install ffmpeg and stop
- Always use
-y flag to avoid interactive prompts
- Use
-c copy for lossless clip extraction when possible (much faster)
- For large files, warn user about processing time before starting long operations
- Default output goes in the same directory as input with a descriptive suffix
- When extracting many frames, create a subdirectory to avoid clutter
- Report output file path and size after completion