-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFramesToVideoNormal.py
More file actions
27 lines (20 loc) · 852 Bytes
/
Copy pathFramesToVideoNormal.py
File metadata and controls
27 lines (20 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import cv2
import os
from tkinter import Tcl
def ImagesToVideo(video_name):
image_folder = 'images'
images = [img for img in os.listdir(image_folder) if img.endswith(".png")]
frame = cv2.imread(os.path.join(image_folder, images[0]))
height, width, layers = frame.shape
fourcc = cv2.VideoWriter_fourcc(*'MP4V')
video = cv2.VideoWriter(video_name, fourcc, 30, (width,height))
images = Tcl().call('lsort', '-dict', images)
for image in images:
video.write(cv2.imread(os.path.join(image_folder, image)))
cv2.destroyAllWindows()
video.release()
for filename in os.listdir(image_folder):
if filename.endswith('.png'):
file_path = os.path.join(image_folder, filename)
os.remove(file_path)
print(f"Deleted: {file_path}",end='\r')