8000 GitHub - imaihub/video-frame-extractor: A Python package and CLI tool based on FFmpeg for extracting frames from video files using customizable strategies, and for retrieving detailed video metadata.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A Python package and CLI tool based on FFmpeg for extracting frames from video files using customizable strategies, and for retrieving detailed video metadata.

License

Notifications You must be signed in to change notification settings

imaihub/video-frame-extractor

Repository files navigation

Video Frame Extractor

A Python package and CLI tool based on FFmpeg for extracting frames from video files using customizable strategies, and for retrieving detailed video metadata.


Features

  • Extract frames from a single video or a directory of videos.
  • Choose from multiple frame extraction strategies:
    • all: extract every frame
    • uniform: extract frames evenly across the video
    • fixed_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

Installation

1. Clone this repository

git clone https://github.com/imaihub/video-frame-extractor.git

2. Install Python dependencies

pip install -r requirements.txt

3. Install FFmpeg and FFprobe

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

Usage

From CLI

Note: the examples below use singular videos, but also work with complete directories with multiple videos.

Extract Frames from a Video (All Frames):

python cli extract --video_path path/to/video.mp4 --output_dir path/to/frames --strategy all

Extract Frames from a Video (Uniform Sampling):

python cli extract --video_path path/to/video.mp4 --output_dir path/to/frames --strategy uniform --fps 1

Extract Frames from a Video (Random Sampling):

python cli extract --video_path path/to/video.mp4 --output_dir path/to/frames --strategy fixed_random --fps 10

Retrieve Metadata:

python main.py metadata --video_path path/to/video.mp4

Optional Flags

Video Frame Extraction

  • --start_time, --end_time – limit the extraction window
  • --allow_any_extension – process all files regardless of extension

Video Frame Extraction or Metadata Retrieval

  • --reset_indices – reset frame numbering starting at 0
  • --verbose – enable detailed logging

Testing

To run tests:

pytest

Tests cover:

  • Frame extraction logic
  • CLI behavior
  • Utility functions

Project Structure

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

License

This project is released under the AGPL 3.0 License.

About

A Python package and CLI tool based on FFmpeg for extracting frames from video files using customizable strategies, and for retrieving detailed video metadata.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0