Skip to main content

High-quality integration for https://supermaker.ai/video/first-last-frame/

Project description

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/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

first_last_frame-1767774.631.530.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

first_last_frame-1767774.631.530-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file first_last_frame-1767774.631.530.tar.gz.

File metadata

File hashes

Hashes for first_last_frame-1767774.631.530.tar.gz
Algorithm Hash digest
SHA256 294b1ff2c583fb925b74acdad71b24b2c779e81adcc796695d0c4812f869d325
MD5 9f29843751c6967c4d64f5df8833cbfd
BLAKE2b-256 75f4ebd998e0c357b3934b6bfc2fda9f74d89c469cc348dfd4e93af1842274a6

See more details on using hashes here.

File details

Details for the file first_last_frame-1767774.631.530-py3-none-any.whl.

File metadata

File hashes

Hashes for first_last_frame-1767774.631.530-py3-none-any.whl
Algorithm Hash digest
SHA256 c9e2e4b0f0d6d911e1d4c0d08d65916361a91757debefeddd474ef707cb00656
MD5 2a971f8e9494aa68e442be3a9f12c718
BLAKE2b-256 18a8c7972cd29ff6d7a7aa7a990df49df116172a9fcf1535048b73831373d407

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page