forked from vipermu/StyleCLIP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_video.py
40 lines (34 loc) · 848 Bytes
/
create_video.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
import cv2
import os
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
'--image_folder',
type=str,
help='',
)
parser.add_argument(
'--video_name',
type=str,
help='',
)
parser.add_argument(
'--rate',
type=int,
default=16,
help='',
)
args = parser.parse_args()
image_folder = args.image_folder
video_name = f'{args.video_name}.avi'
images = [img for img in os.listdir(image_folder) if img.endswith(".png")]
images = [int(x[:-4]) for x in images]
images.sort()
images = [f"{x}.png" for x in images]
frame = cv2.imread(os.path.join(image_folder, images[0]))
height, width, layers = frame.shape
video = cv2.VideoWriter(video_name, 0, args.rate, (width,height))
for image in images:
video.write(cv2.imread(os.path.join(image_folder, image)))
cv2.destroyAllWindows()
video.release()