FirstFrame
Overview
FirstFrame is a lightweight command-line tool that extracts the first frame from MP4 video files using OpenCV (cv2).
It automatically scans the current directory for .mp4 files (case-insensitive), displays an interactive numbered list with file sizes, lets the user select a video, and saves the first frame as an image file (PNG by default; supports JPG, JPEG, BMP, TIFF).
The tool features clear prompts, basic error handling, and a pause at the end — perfect for quick thumbnail generation, cover image creation, or inspecting video starts without loading the entire file.
Features
- Finds all
.mp4/.MP4/.Mp4files in the current folder usingglob - Shows numbered list with file sizes (in MB) for easy selection
- Extracts the very first frame reliably with a single
cap.read()call - Smart default output filename:
output.png(if free) or{video_name}_first.png - Automatically adds
.pngextension if user input lacks an image suffix - Clean resource handling (
cap.release()) — no temporary files - User-friendly success/error messages and final confirmation
Prerequisites
- Python 3.8+ (recommended: 3.10–3.12)
opencv-python(installed via pip)- Optional: virtual environment (
venvoruv)
No C compiler or Cython is required for normal usage — the project is currently pure Python.
Installation
Development / Source Install (Editable)
# 1. Clone or download the repo
git clone <your-repo-url>
cd FirstFrame
# 2. (Recommended) Create & activate virtual environment
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 3. Install dependencies
pip install opencv-python
# If you later add ChronicleLogger or others → add them here
# 4. Install project in editable mode
pip install -e .
Now you can run it with:
python -m FirstFrame
Future PyPI Release (when ready)
pip install firstframe
(You would then publish it via python -m build + twine, and configure console_scripts in pyproject.toml for a firstframe command.)
Usage
Place your MP4 videos in the current directory and run:
python -m FirstFrame
Example session:
Found MP4 videos:
1. intro.mp4 (12.4 MB)
2. demo.MP4 (45.8 MB)
Enter video number (1-2): 1
Selected: intro.mp4
Enter output image filename [default: output.png]:
Extracting first frame from 'intro.mp4'...
Success: First frame saved as 'output.png'
Done! Image saved as: output.png
Press Enter to exit...
Or specify a custom name:
Enter output image filename [default: intro_first.png]: cover.jpg
The tool saves the image and waits for you to press Enter before closing.
For scripting / automation:
from FirstFrame.__main__ import main
main()
Project Structure
Follows modern Python packaging conventions with src/ layout:
FirstFrame/
├── README.md
├── pyproject.toml # (add when packaging properly)
├── src/
│ └── FirstFrame/
│ ├── __init__.py
│ └── __main__.py # Main logic + entry point
└── (optional future folders)
├── tests/
└── docs/
Development Notes
- The core logic lives in
src/FirstFrame/__main__.py - To add features (batch mode, other formats, progress bar…): edit the
main()andget_first_frame()functions - Logging:
ChronicleLoggeris imported but unused — either integrate it or remove the import - Tests: Consider adding
tests/folder +pytestlater - Packaging: When ready, add
pyproject.tomlwithbuild-system = {requires = ["hatchling"], build-backend = "hatchling.build"}(or setuptools)
Troubleshooting
- Cannot open video → Check file path, integrity, and codec support in your OpenCV build
- No MP4 files found → Make sure videos are in the current working directory (
pwd) - OpenCV not found →
pip install opencv-python - Permission denied on save → Check write permissions in current folder
License
MIT License
(Add a LICENSE file with the standard MIT text when you publish or share the repo.)
Metadata
Release files for FirstFrame 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| firstframe-1.0.7.tar.gz | 4.7 kB | Without provenance | Details for firstframe-1.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| firstframe-1.0.7-py3-none-any.whl | Python 3 | none | any | Details for firstframe-1.0.7-py3-none-any.whl |
Total release size: 10.0 kB
Release files / firstframe-1.0.7.tar.gz
| Download URL | firstframe-1.0.7.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2cf341ed4089c848a0196c498e7a86b6b3443f9a99972a5ce99c1c7b5913a28f
|
|
BLAKE2b-256 checksum How to use checksums |
961b5e9895552cb47f57228e33a4b7135ce58ff4424392dba2fe4b837a703be7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Release files / firstframe-1.0.7-py3-none-any.whl
| Download URL | firstframe-1.0.7-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a07535a6b3c3dc4ba4d2d6cbd94cb00003e82cc5b2a71a4259fea78729f878e
|
|
BLAKE2b-256 checksum How to use checksums |
1b5c4b7cb88c8779a088c3adae224df64e2bfc90fb011ee7cbaf7404408a440d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Security for FirstFrame 1.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.