Skip to main content

Video Frame Extractor - Extract frames from videos using FFmpeg

Project description

Video Frame Extractor Tool

A powerful video frame extractor command-line tool and Python library to extract frames from video files using FFmpeg.

PyPI version GitHub

Why Use This Video Frame Extractor?

This video frame extractor tool makes it easy to extract frames from any video file. Whether you need to create thumbnails, analyze video content, or build training datasets, this video frame extractor provides a simple yet powerful solution.

Video Frame Extractor Features

  • Extract frames at custom frame rates (e.g., 1 fps, 5 fps, or original)
  • Support for multiple output formats: JPG, PNG, WebP
  • Adjustable image quality settings for the video frame extractor output
  • Extract frames from specific time ranges
  • Resize/scale output frames
  • Simple CLI and Python API for video frame extraction
  • No Python dependencies (uses built-in modules only)

Requirements for Video Frame Extractor

  • Python 3.7+
  • FFmpeg installed and available in PATH

Installing FFmpeg

macOS:

brew install ffmpeg

Ubuntu/Debian:

sudo apt update && sudo apt install ffmpeg

Windows: Download from ffmpeg.org and add to PATH.

Install Video Frame Extractor

pip install video-frame-extractor-tool

Video Frame Extractor Quick Start

Command Line Video Frame Extractor

# Extract 1 frame per second as JPG (default)
video2frames video.mp4 -o frames/

# Extract at 5 fps as PNG
video2frames video.mp4 -o frames/ -f 5 --format png

# Extract frames from 10s to 30s
video2frames video.mp4 -o frames/ --start 10 --end 30

# Show video information
video2frames video.mp4 --info

Python Video Frame Extractor API

from video2frames import extract_frames, get_video_info

# Get video information
info = get_video_info("video.mp4")
print(f"Resolution: {info.width}x{info.height}")
print(f"Duration: {info.duration} seconds")
print(f"FPS: {info.fps}")

# Extract frames using video frame extractor
frames = extract_frames(
    "video.mp4",
    output_dir="frames",
    fps=2,
    format="png",
    quality=95
)
print(f"Extracted {len(frames)} frames")

Video Frame Extractor CLI Options

Option Description Default
video Path to input video file (required)
-o, --output Output directory for extracted frames frames
-f, --fps Frames per second to extract 1
--format Output format: jpg, png, webp jpg
-q, --quality Image quality (1-100) 90
--start Start time in seconds None
--end End time in seconds None
--prefix Filename prefix for extracted frames frame
--scale Output resolution (e.g., -1:720) None
--info Show video info and exit False
-v, --verbose Verbose output False

Video Frame Extractor Examples

Extract Frames at Different Frame Rates

Use the video frame extractor to extract frames at various rates:

# 1 frame per second (good for long videos)
video2frames video.mp4 -o frames/ -f 1

# 5 frames per second
video2frames video.mp4 -o frames/ -f 5

# Original frame rate (e.g., 30 fps)
video2frames video.mp4 -o frames/ -f 30

Video Frame Extractor Output Formats

The video frame extractor supports multiple output formats:

# JPEG (smaller files)
video2frames video.mp4 -o frames/ --format jpg

# PNG (lossless quality)
video2frames video.mp4 -o frames/ --format png

# WebP (modern format, good compression)
video2frames video.mp4 -o frames/ --format webp

Extract Frames from Specific Time Range

# Extract frames from 1:00 to 2:00
video2frames video.mp4 -o frames/ --start 60 --end 120

# First 30 seconds only
video2frames video.mp4 -o frames/ --end 30

Resize Extracted Frames

# Resize to 720p (keep aspect ratio)
video2frames video.mp4 -o frames/ --scale -1:720

# Resize to specific dimensions
video2frames video.mp4 -o frames/ --scale 1280:720

Batch Video Frame Extraction

Process multiple videos with the video frame extractor:

# Process multiple videos
for video in *.mp4; do
    video2frames "$video" -o "${video%.mp4}_frames/"
done

Video Frame Extractor Python API Reference

extract_frames()

The main function of the video frame extractor:

extract_frames(
    video_path: str,
    output_dir: str = "frames",
    fps: float = 1.0,
    format: str = "jpg",
    quality: int = 90,
    start_time: Optional[float] = None,
    end_time: Optional[float] = None,
    prefix: str = "frame",
    scale: Optional[str] = None,
    overwrite: bool = True,
    verbose: bool = False
) -> List[Path]

get_video_info()

Get video information before using the video frame extractor:

get_video_info(video_path: str) -> Optional[VideoInfo]

Returns a VideoInfo object with:

  • width: Video width in pixels
  • height: Video height in pixels
  • fps: Frame rate
  • duration: Duration in seconds
  • total_frames: Estimated total frames

check_ffmpeg()

Check if FFmpeg is available for the video frame extractor:

check_ffmpeg() -> bool

Returns True if FFmpeg is available.

Video Frame Extractor Use Cases

  • Create video thumbnails - Extract key frames for video previews
  • Build ML training datasets - Use the video frame extractor to create image datasets from videos
  • Video analysis - Extract frames for motion analysis or quality inspection
  • Content creation - Get still images from video content
  • Documentation - Create step-by-step screenshots from tutorial videos

License

MIT License - see LICENSE file.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

video_frame_extractor_tool-0.2.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

video_frame_extractor_tool-0.2.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file video_frame_extractor_tool-0.2.0.tar.gz.

File metadata

File hashes

Hashes for video_frame_extractor_tool-0.2.0.tar.gz
Algorithm Hash digest
SHA256 37984a7619590a608b896bc3a097808fa1009d4e5a37bb308688485ea9ed55dc
MD5 1ccab932dab85b02130ab183a5f13942
BLAKE2b-256 1f931ad9a7c6481970838581f2dad7cfff4d6aaf9f7b7b1d53714f1916789837

See more details on using hashes here.

File details

Details for the file video_frame_extractor_tool-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for video_frame_extractor_tool-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b817ada7758d1d968eb5777c48fa9500750fbd00c4b7008f0f28b6126824a73
MD5 96ed2e634f0086d2d5a3e19e88693137
BLAKE2b-256 a92792a07c920072748591aa493ff4eaf566023d030ab237116d82092bdbe6c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page