-
Notifications
You must be signed in to change notification settings - Fork 0
/
vid_maker.py
52 lines (38 loc) · 1.44 KB
/
vid_maker.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
41
42
43
44
45
46
47
48
49
50
51
52
#this program creates a lossless video from images
import cv2
import os
from PIL import Image
image_folder = '/home/large_data/venus_work/test/'
video_name = '/home/large_data/venus_work/test/video2.avi'
#print(cv2.__version__)
#
#vid = cv2.VideoCapture('video.mp4')
#if not vid.isOpened():
# raise IOError("Couldn't open webcam or video")
video_FourCC = cv2.VideoWriter_fourcc(*'MPEG')
#video_fps = vid.get(cv2.CAP_PROP_FPS)
#video_size = (int(vid.get(cv2.CAP_PROP_FRAME_WIDTH)), int(vid.get(cv2.CAP_PROP_FRAME_HEIGHT)))
#print(video_FourCC)
#print(video_fps)
#print(video_size)
images = [img for img in os.listdir(image_folder) if img.endswith(".tiff")]
for infile in images:
# print "is tif or bmp"
outfile = os.path.join(image_folder, infile[:-4] + "jpeg")
im = Image.open(os.path.join(image_folder,infile))
print(im.size)
print ("new filename : " + outfile)
im = im.convert("RGB")
out = im.resize((1920,1440),Image.ANTIALIAS)
out.save(outfile, "JPEG", quality=95)
images = [img for img in os.listdir(image_folder) if img.endswith(".jpeg")]
frame = cv2.imread(os.path.join(image_folder, images[0]))
height, width, layers = frame.shape
print(frame.shape)
video = cv2.VideoWriter(video_name, video_FourCC, 30, (width, height))
for j in range(30):
for image in images:
print("Writing the image : ", image)
video.write(cv2.imread(os.path.join(image_folder, image)))
cv2.destroyAllWindows()
video.release()