https://github.com/unvercan/video-to-frames-converter
Video to Frames Converter
https://github.com/unvercan/video-to-frames-converter
convert frame image opencv python video
Last synced: over 1 year ago
JSON representation
Video to Frames Converter
- Host: GitHub
- URL: https://github.com/unvercan/video-to-frames-converter
- Owner: unvercan
- License: mit
- Created: 2020-10-31T17:46:37.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-13T23:33:09.000Z (over 1 year ago)
- Last Synced: 2025-02-14T00:29:45.899Z (over 1 year ago)
- Topics: convert, frame, image, opencv, python, video
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Video to Frames Converter
A Python script that extracts frames from a video file and saves them as images.
## Features
- Extracts frames from a video and saves them in a specified format.
- Allows specifying a start and end frame range.
- Uses OpenCV for video processing.
- Supports command-line arguments for flexibility.
- Creates an output directory if it doesn't exist.
## Prerequisites
Ensure you have the following installed:
- Python 3.7+
- OpenCV (`cv2`)
Install dependencies using:
```bash
pip install -r requirements.txt
```
## Usage
Run the script using command-line arguments:
```bash
python main.py -i input.mp4 -o frames -p frame -f jpg -s 10 -e 100
```
### Command-Line Arguments:
| Argument | Description | Default |
|------------------|---------------------------------------|-------------|
| `-i`, `--input` | Path to the input video file | `input.mp4` |
| `-o`, `--output` | Directory to save extracted frames | `frames/` |
| `-p`, `--prefix` | Prefix for frame filenames | `frame` |
| `-f`, `--format` | Image format (e.g., jpg, png) | `jpg` |
| `-s`, `--start` | Start frame index | `0` |
| `-e`, `--end` | End frame index (None for all frames) | `None` |
## Example
Extract frames from `video.mp4`, save them as PNG, starting from frame 50 to 200:
```bash
python main.py -i video.mp4 -o output_frames -p img -f png -s 50 -e 200
```
## Project Structure
```
project-folder/
│── app.py # Main processing logic
│── main.py # CLI entry point
│── config.py # Default configurations
│── requirements.txt # Dependencies
│── README.md # Documentation
```
## License
This project is licensed under the MIT License.