How-To & Life · Guide · Audio, Video & Voice
How to extract video frames
Perform single-frame or interval extraction while preserving native resolution. Free online reference for choosing JPG or PNG output with no signup needed.
Extracting a still frame from a video sounds simple — until you need 2,400 evenly spaced frames from a 2-minute clip for a machine learning dataset, or a single frame at exactly 00:01:23.416 for a thumbnail, or every keyframe from an hour of surveillance footage. The difference between “decent” and “actually useful” extraction is understanding what the video codec stores versus what your tool can reconstruct. This guide covers single-frame versus batch extraction, keyframes versus interpolated frames, FFmpeg’s fps filter, output quality settings, naming conventions that keep batches sane, and the use cases — thumbnails, ML training data, timelapse, manual review — that drive the choices.
Advertisement
Single frame at a specific moment
For thumbnails and hero stills, you want one frame at a precise time. FFmpeg handles this with seek plus single-frame output.
# Extract one frame at 00:01:23 ffmpeg -ss 00:01:23 -i input.mp4 -vframes 1 -q:v 2 frame.jpg # Quality scale 2 is near-max JPEG quality (scale is 2-31, lower=better) # For PNG (lossless): ffmpeg -ss 00:01:23 -i input.mp4 -vframes 1 frame.png
Seek fast by putting -ss before -i (jumps to nearest keyframe, fast). Seek precisely by putting -ss after -i (decodes from start, slow but frame-accurate). The combined form is the compromise — fast seek close, then precise adjust.
Sequence extraction: the fps filter
For extracting N frames from a video (thumbnails strip, ML training), use the fps filter to control rate. fps=1 means one frame per second of video.
# One frame per second, named frame_0001.jpg, frame_0002.jpg... ffmpeg -i input.mp4 -vf fps=1 -q:v 2 frame_%04d.jpg # Two frames per second (every 0.5s) ffmpeg -i input.mp4 -vf fps=2 frame_%04d.jpg # Every 10th frame from original (assuming 30fps source) ffmpeg -i input.mp4 -vf "select=not(mod(n\,10))" -vsync vfr out_%04d.jpg # Every frame (same rate as source) ffmpeg -i input.mp4 frame_%04d.png
The %04d in the filename is a zero-padded counter. Use 4 digits for batches up to 9,999 frames, 5 for bigger. Padding keeps files sorting in chronological order in file managers.
Keyframes vs interpolated frames
Keyframes (I-frames) are self-contained and high quality. P and B frames are deltas from surrounding frames and, once decoded, are identical quality to keyframes — but extracting only keyframes skips most of the video and is much faster.
# Extract only keyframes (I-frames) ffmpeg -skip_frame nokey -i input.mp4 -vsync 0 -frame_pts true \ keyframe_%04d.jpg
Keyframe-only extraction is the right choice for long recordings where you want a sparse sampling — CCTV review, dashcam footage, long lectures. You get one frame every few seconds (depending on the encode’s GOP size) with near-zero decode cost.
Scene detection
For extracting frames at significant visual changes (new scenes, cuts), use the scene change detector. Useful for building storyboard thumbnails.
# Extract frames where scene change score > 0.4 ffmpeg -i input.mp4 -vf "select='gt(scene,0.4)'" -vsync vfr \ scene_%04d.jpg
Tune the threshold: 0.4 is a moderate cut, 0.2 catches subtle transitions, 0.6 only catches hard cuts. Scene detection is imperfect — fast pans and lighting changes trigger it too — but it’s a good starting point for automated storyboarding.
Output formats: JPEG, PNG, WebP
JPEG — smallest, lossy, good for thumbnails and previews. Use -q:v 2 for high quality (typical: 100–300KB per frame at 1080p).
PNG — lossless, larger, best for pixel-perfect analysis, ML training where compression artifacts might confuse a model, or compositing into other software.
WebP — smaller than JPEG at same quality, supports lossless mode, good default for modern web.
TIFF/BMP — uncompressed, huge files, only for pro compositing or archival workflows.
Resolution and quality control
# Downscale to 640 wide during extraction ffmpeg -i input.mp4 -vf "fps=1,scale=640:-1" frame_%04d.jpg # Extract at source resolution (default) ffmpeg -i input.mp4 -vf fps=1 frame_%04d.jpg # High-quality JPEG (q=2) ffmpeg -i input.mp4 -vf fps=1 -q:v 2 frame_%04d.jpg # Smaller JPEG (q=10, still looks decent) ffmpeg -i input.mp4 -vf fps=1 -q:v 10 frame_%04d.jpg
Naming conventions for batches
For ML datasets and batch review, include enough metadata in the filename to sort and locate files later. Good patterns:
sourceclip_000001.jpg # simple numeric sourceclip_t00h01m23s.jpg # timestamp in name sourceclip_frame000123_t83s.jpg # frame number + second 20240423_cam1_00005.jpg # date + source + counter
Avoid spaces, uppercase, and special characters. Use zero-padded numbers so alphabetical sort equals chronological sort. Include the source video identifier so you don’t lose track after combining multiple extractions.
Use case: thumbnail strips
A thumbnail strip (“sprite sheet”) packs N frames into one image for a scrubber preview or contact sheet. Extract frames at regular intervals, then tile them with ImageMagick or FFmpeg’s tile filter.
# 10 frames in a 5x2 grid, each 160px wide ffmpeg -i input.mp4 -vf "fps=10/duration,scale=160:-1,tile=5x2" \ -frames:v 1 sprites.jpg
Use case: ML training data
For training computer vision models, extract frames at intervals that capture meaningful variation but avoid near-duplicates. A good heuristic: 0.5–2 frames per second for general content, 1 per keyframe for sparse sampling, every Nth frame (where N matches your model’s temporal resolution) for action recognition.
Always extract at source resolution to PNG for training. Let the training pipeline downscale; don’t bake in a lossy JPEG at the extraction stage.
Use case: time-lapse source frames
For making a time-lapse, extract evenly-spaced frames from a long source and reassemble at high frame rate.
# Extract every 30th frame as PNG ffmpeg -i 10hour_timelapse.mp4 -vf "select=not(mod(n\,30))" \ -vsync vfr tl_%04d.png # Reassemble at 24fps: ffmpeg -framerate 24 -i tl_%04d.png -c:v libx264 \ -crf 18 -pix_fmt yuv420p output.mp4
Batch timestamp on extracted frames
If you need to know the source timestamp of each frame, extract with verbose logging and parse the PTS, or name files with the timestamp directly:
ffmpeg -i input.mp4 -vf fps=1 \ -frame_pts 1 frame_%d.jpg # This names files by their source timestamp (in time base units)
Common mistakes
Using -ss after -i for long videos. Decodes from the beginning every time. For a single frame at 1 hour into a 2-hour video, this takes minutes instead of seconds.
Forgetting the padding width. %d without zero padding sorts 1, 10, 100, 2, 20... Use %04d or wider.
Extracting every frame when you only need keyframes. Writes thousands of near-duplicate images. Use keyframe-only extraction for surveillance-style footage.
Defaulting to JPEG for ML training. JPEG artifacts can confuse models that need to distinguish fine textures. Use PNG for training data.
Skipping quality flag for JPEG. FFmpeg’s default quality scale is 5, which is mediocre. Use -q:v 2 for archival-quality stills.
Scene detection at default threshold. The default of 0.4 is a starting point, not a universal setting. Tune per source.
No plan for output directory. Extracting 10,000 frames into your home folder is a mess. Create a dedicated output directory first.
Run the numbers
Pull single frames or full sequences from video without installing FFmpeg using the video frame extractor. Pair with the video trimmer to cut the clip down to the region of interest before batch extraction, and the image resizer for bulk-resizing extracted frames to a uniform dimension for thumbnails or dataset prep.
Use these while you read
Tools that pair with this guide
- Video Frame ExtractorGrab any frame from a video as a PNG or JPG image instantly. Scrub to the exact second and save, great for thumbnails—free, browser-only, with no uploads.Audio, Video & Voice
- Video TrimmerCut MP4 and WebM videos directly in your browser. Set start and end points, preview, and save the clip with no watermark or uploads—free and instant.Audio, Video & Voice
- Image CompressorReduce JPG file sizes with a quality slider and download optimized images for emails or websites. A free, instant online compressor that works in your browser with no signup.File & Format Converters
- Dummy Image PlaceholderGenerate placeholder images with custom sizes and colors online. Download or copy to clipboard in seconds — free, browser-only tool with no ads.Audio, Video & Voice
Advertisement
Continue reading
- How-To & LifeHow to Start Drone PhotographyStart drone photography the right way: understand FAA Part 107 and TRUST, pick a drone tier, avoid no‑fly zones, and master ND filters. Free instant guide, no sign-up.
- How-To & LifeHow to Pick Colors From ImagesExtract colors from images using eyedropper tools—hex at cursor, screenshot sampling, brand matching. A free online workflow guide with accessibility tips, no sign-up.
- How-To & LifeHow to Extract Colors From ImagesCompare dominant vs average color extraction and grab brand palettes from logos. Free online guide on algorithms and use cases with instant access.
- How-To & LifeHow to Blur Faces in PhotosBlur faces using pixelation or Gaussian techniques, and learn why mild blur can be reversed. A free online guide for privacy-safe censoring in seconds.
- How-To & LifeHow to View EXIF Metadata in PhotosExtract hidden camera data and settings from any photo with a free, online EXIF viewer. Verify image authenticity and check capture time instantly in your browser, no sign-up.
- How-To & LifeHow to Remove EXIF Metadata From PhotosStrip GPS, camera, and time data from images losslessly free online. Protect your privacy by understanding EXIF risks instantly with no download needed.