This Python script converts a series of PNG images into a video file, where each image is displayed for exactly 5 seconds. The script utilizes the OpenCV library to create the video. The images should be named numerically (e.g., 1.png
, 2.png
, ...) and placed in a directory. The script then sorts and processes the images, ensuring that each image is shown for the desired duration in the final video.
- Converts a sequence of PNG images into a video
- Customizable frame duration (5 seconds per image)
- Automatically sorts images based on their numeric filenames
- Supports Windows file paths
- Python 3.x
- OpenCV library (
pip install opencv-python
)
-
Clone this repository to your local machine or download the script directly.
git clone https://github.com/yourusername/image-to-video-converter.git
-
Place your PNG images (e.g., 1.png, 2.png, ...) in a directory of your choice.
-
Open the convert_images_to_video.py script in a text editor.
-
Update the image_directory variable to point to the directory containing your PNG images. For example:
image_directory = "C:\\path\\to\\your\\images\\directory"
-
Run the script using the following command:
python convert_images_to_video.py
-
The script will generate an output video named output_video.mp4 in the same directory as the script.
You can adjust the frame_duration variable in the script to change the duration each image is displayed in the video. The default is set to 5 seconds (5000 milliseconds).
Author Created by SANAT KUMAR MISHRA.