This Python script analyzes an input video and identifies keyframes based on structural similarity index (SSIM) differences between consecutive frames. The identified keyframes are saved in a separate folder named "synth_frames" for further processing with tools like stable diffusion and ebsynth.
- Frame extraction from input video
- Frame comparison using structural similarity index (SSIM)
- Keyframe identification based on a predefined threshold
- Saving keyframes with dynamic leading zeros based on total number of frames in the input video
- Progress bars for processing frames and saving keyframes
- Python 3.x
- OpenCV
- scikit-image
- numpy
- tqdm
-
Install Python 3.x if not already installed.
-
Clone this repository or download the script.
-
Install the required Python libraries:
pip install opencv-python-headless scikit-image numpy tqdm
Edit the INPUT_VIDEO and OUTPUT_PATH constants in the script to specify the input video file and the output directory for saving keyframes.
(Optional) Adjust the FRAME_RATE and THRESHOLD constants to change the frame rate for processing and the threshold for keyframe identification.
Run the script:
python video_keyframe_detection.py
The identified keyframes will be saved in the "synth_frames" folder inside the specified output directory.
The script is designed to work with various video lengths and adjusts the leading zeros for saved keyframes dynamically based on the total number of frames in the input video. This script provides a basic outline for the desired functionality. You will need to set up and integrate stable diffusion and ebsynth tools for further processing of the keyframes