A Python package and CLI tool based on FFmpeg for extracting frames from video files using customizable strategies, and for retrieving detailed video metadata.
- Extract frames from a single video or a directory of videos.
- Choose from multiple frame extraction strategies:
all
: extract every frameuniform
: extract frames evenly across the videofixed_random
: extract a fixed number of frames at random
- Retrieve video metadata using
ffprobe
- Supports
.mp4
,.avi
,.mov
,.mkv
,.webm
formats - Built-in CLI with verbose logging option
git clone https://github.com/imaihub/video-frame-extractor.git
pip install -r requirements.txt
This tool relies on FFmpeg for video decoding, therefore you must have ffmpeg
and ffprobe
installed and added to your system PATH
.
sudo apt install ffmpeg
Check installation:
ffmpeg -version
ffprobe -version
Note: the examples below use singular videos, but also work with complete directories with multiple videos.
python cli extract --video_path path/to/video.mp4 --output_dir path/to/frames --strategy all
python cli extract --video_path path/to/video.mp4 --output_dir path/to/frames --strategy uniform --fps 1
python cli extract --video_path path/to/video.mp4 --output_dir path/to/frames --strategy fixed_random --fps 10
python main.py metadata --video_path path/to/video.mp4
--start_time
,--end_time
– limit the extraction window--allow_any_extension
– process all files regardless of extension
--reset_indices
– reset frame numbering starting at 0--verbose
– enable detailed logging
To run tests:
pytest
Tests cover:
- Frame extraction logic
- CLI behavior
- Utility functions
vfe/
├── __init__.py
├── cli.py
├── frame_extraction_strategy.py
├── logging_config.py
├── main.py
├── utils.py
├── video_frame_extractor.py
├── tests/
│ ├── __init__.
│ ├── conftest.py
│ ├── test_cli.py
│ ├── test_extractor.py
│ └── test_utils.py
├── LICENSE.md
├── README.md
├── requirements.txt
This project is released under the AGPL 3.0 License.