first-last-frame
A Python library to automatically extract the first and last frames from video files, providing a simple and efficient way to represent video content with key visual snapshots. This package is designed to integrate seamlessly with the first-last-frame capabilities offered at https://supermaker.ai/video/first-last-frame/.
Installation
Install the package using pip: bash pip install first-last-frame
Basic Usage
Here are a few examples demonstrating how to use the first-last-frame library:
1. Extracting frames from a local video file: python from first_last_frame import extract_frames
video_path = "path/to/your/video.mp4" output_dir = "output/frames"
try: first_frame_path, last_frame_path = extract_frames(video_path, output_dir) print(f"First frame saved to: {first_frame_path}") print(f"Last frame saved to: {last_frame_path}") except Exception as e: print(f"An error occurred: {e}")
2. Specifying custom filenames for the extracted frames: python from first_last_frame import extract_frames
video_path = "path/to/your/video.mp4" output_dir = "output/frames" first_frame_filename = "my_first_frame.jpg" last_frame_filename = "my_last_frame.png" # Different extension example
try: first_frame_path, last_frame_path = extract_frames(video_path, output_dir, first_frame_filename, last_frame_filename) print(f"First frame saved to: {first_frame_path}") print(f"Last frame saved to: {last_frame_path}") except Exception as e: print(f"An error occurred: {e}")
3. Handling videos that might not exist: python from first_last_frame import extract_frames import os
video_path = "path/to/a/nonexistent/video.mp4" output_dir = "output/frames"
if os.path.exists(video_path): try: first_frame_path, last_frame_path = extract_frames(video_path, output_dir) print(f"First frame saved to: {first_frame_path}") print(f"Last frame saved to: {last_frame_path}") except Exception as e: print(f"An error occurred: {e}") else: print(f"Video file not found: {video_path}")
4. Extracting frames and handling potential directory creation errors: python from first_last_frame import extract_frames import os
video_path = "path/to/your/video.mp4" output_dir = "new_output_directory"
try: # Ensure the output directory exists if not os.path.exists(output_dir): os.makedirs(output_dir)
first_frame_path, last_frame_path = extract_frames(video_path, output_dir)
print(f"First frame saved to: {first_frame_path}")
print(f"Last frame saved to: {last_frame_path}")
except OSError as e: print(f"Error creating directory: {e}") except Exception as e: print(f"An error occurred: {e}")
Features
- Simple Extraction: Easily extract the first and last frames from any video file.
- Customizable Output: Specify the output directory for the extracted frames.
- Filename Control: Define custom filenames for the first and last frames.
- Error Handling: Gracefully handles potential errors such as missing files or invalid video formats.
- Cross-Platform Compatibility: Works on various operating systems with Python support.
- Dependency Management: Relies on common and easily installable Python packages.
License
MIT License
This project is a gateway to the first-last-frame ecosystem. For advanced features and full capabilities, please visit: https://supermaker.ai/video/first-last-frame/
Metadata
Release files for first-last-frame 1767774.631.530
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 |
|---|---|---|---|---|
| first_last_frame-1767774.631.530.tar.gz | 4.0 kB | Without provenance | Details for first_last_frame-1767774.631.530.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| first_last_frame-1767774.631.530-py3-none-any.whl | Python 3 | none | any | Details for first_last_frame-1767774.631.530-py3-none-any.whl |
Total release size: 8.6 kB
Release files / first_last_frame-1767774.631.530.tar.gz
| Download URL | first_last_frame-1767774.631.530.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
294b1ff2c583fb925b74acdad71b24b2c779e81adcc796695d0c4812f869d325
|
|
BLAKE2b-256 checksum How to use checksums |
75f4ebd998e0c357b3934b6bfc2fda9f74d89c469cc348dfd4e93af1842274a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / first_last_frame-1767774.631.530-py3-none-any.whl
| Download URL | first_last_frame-1767774.631.530-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9e2e4b0f0d6d911e1d4c0d08d65916361a91757debefeddd474ef707cb00656
|
|
BLAKE2b-256 checksum How to use checksums |
18a8c7972cd29ff6d7a7aa7a990df49df116172a9fcf1535048b73831373d407
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for first-last-frame 1767774.631.530
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.