Downloads · 30 days
0
qy-upup/first-last-frame
first-last-frame is a machine learning model from qy-upup. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This repository contains code related to extracting the first and last frames from video files. This functionality is part of the broader first-last-frame ecosystem, designed to streamline video analysis and content c…
Downloads · 30 days
0
Access
Public
Updated Jan 7, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md4.3 KB · 99%
From the Hugging Face model README
This repository contains code related to extracting the first and last frames from video files. This functionality is part of the broader first-last-frame ecosystem, designed to streamline video analysis and content creation workflows. You can learn more about the first-last-frame project at https://supermaker.ai/video/first-last-frame/.
The code provided in this repository enables users to efficiently extract the first and last frames from a video file. This can be useful for a variety of applications, including:
The core functionality focuses on providing a simple and reliable method for obtaining these key frames, abstracting away the complexities of video decoding and frame manipulation. The package prioritizes speed and ease of use.
This code is intended for developers and researchers working with video data. It can be integrated into larger systems for automated video processing, content management, or machine learning applications. Specifically, it is designed for scenarios where quick access to the first and last frames of a video is required.
Potential use cases include:
While this code provides a convenient way to extract first and last frames, it has some limitations:
Here's a basic example of how you might use the code to extract the first and last frames from a video: python
import cv2
def extract_first_last_frame(video_path, output_path_first, output_path_last): """Extracts the first and last frame of a video and saves them as images.""" vidcap = cv2.VideoCapture(video_path) success, image = vidcap.read() # Read the first frame if success: cv2.imwrite(output_path_first, image) # Save the first frame
# Get total number of frames
total_frames = int(vidcap.get(cv2.CAP_PROP_FRAME_COUNT))
# Move to the last frame
vidcap.set(cv2.CAP_PROP_POS_FRAMES, total_frames - 1)
success, image = vidcap.read()
if success:
cv2.imwrite(output_path_last, image) # Save the last frame
vidcap.release()
print(f"First frame saved to: {output_path_first}")
print(f"Last frame saved to: {output_path_last}")
video_file = "path/to/your/video.mp4" first_frame_output = "first_frame.jpg" last_frame_output = "last_frame.jpg"
extract_first_last_frame(video_file, first_frame_output, last_frame_output)
**Note:** This is a simplified example. You'll likely need to adapt it to your specific needs and environment, including installing necessary libraries like OpenCV (`pip install opencv-python`). Refer to the documentation of the underlying video processing library you choose for detailed usage instructions.