This script is designed to extract frames from video files and save them as individual images with unique identifiers. It utilizes OpenCV for video processing and UUID module to generate unique filenames for the extracted frames.
- Python 3.x
- OpenCV (
cv2
), UUID, and OS modules
- Ensure you have Python installed on your system.
- Install the required modules using pip:
pip install opencv-python-headless
- Place your video files in the
Video Files/
directory. - Run the script.
python frame_extractor.py
- Extracted frames will be saved in the
frames/
directory.
- Function to extract frames from a video file.
- Parameters:
input_file
: Path to the input video file.output_directory
: Directory to save the extracted frames.
- It reads the video file, extracts frames at every 5th frame, generates a unique filename for each frame, and saves the frames as JPEG images in the specified output directory.
- The script iterates over each file in the
Video Files/
directory. - If the file has a
.mp4
or.avi
extension, it calls thesave_frames_with_uuid
function to extract frames from the video.
frame_extractor.py
: Main script for extracting frames.Video Files/
: Directory containing input video files.frames/
: Directory to save the extracted frames.