create video from images python

Solutions on MaxInterview for create video from images python by the best coders in the world

showing results for - "create video from images python"
Giorgia
07 Sep 2018
1import cv2
2import numpy as np
3import glob
4
5img_array = []
6for filename in glob.glob('C:/New folder/Images/*.jpg'):
7    img = cv2.imread(filename)
8    height, width, layers = img.shape
9    size = (width,height)
10    img_array.append(img)
11
12
13out = cv2.VideoWriter('project.avi',cv2.VideoWriter_fourcc(*'DIVX'), 15, size)
14 
15for i in range(len(img_array)):
16    out.write(img_array[i])
17out.release()
Julian
08 Jun 2017
1  import cv2
2  import numpy as np
3  
4  # choose codec according to format needed
5  fourcc = cv2.VideoWriter_fourcc(*'mp4v') 
6  video = cv2.VideoWriter('video.avi', fourcc, 1, (width, height))
7
8  for j in range(0,5):
9     img = cv2.imread(str(i) + '.png')
10     video.write(img)
11
12  cv2.destroyAllWindows()
13  video.release()
14
Bryanna
26 Apr 2020
1import os 
2import cv2  
3from PIL import Image  
4  
5print(os.getcwd())  
6  
7os.chdir("C:\\Python\\Geekfolder2")   
8path = "C:\\Python\\Geekfolder2"
9  
10mean_height = 0
11mean_width = 0
12  
13num_of_images = len(os.listdir('.')) 
14  
15for file in os.listdir('.'): 
16    im = Image.open(os.path.join(path, file)) 
17    width, height = im.size 
18    mean_width += width 
19    mean_height += height 
20    
21  
22mean_width = int(mean_width / num_of_images) 
23mean_height = int(mean_height / num_of_images) 
24  
25  
26for file in os.listdir('.'): 
27    if file.endswith(".jpg") or file.endswith(".jpeg") or file.endswith("png"): 
28        
29        im = Image.open(os.path.join(path, file))  
30   
31        
32        width, height = im.size    
33        print(width, height) 
34  
35        
36        imResize = im.resize((mean_width, mean_height), Image.ANTIALIAS)  
37        imResize.save( file, 'JPEG', quality = 95) 
38        
39        print(im.filename.split('\\')[-1], " is resized"40  
41  
42def generate_video(): 
43    image_folder = '.'
44    video_name = 'mygeneratedvideo.avi'
45    os.chdir("C:\\Python\\Geekfolder2") 
46      
47    images = [img for img in os.listdir(image_folder) 
48              if img.endswith(".jpg") or
49                 img.endswith(".jpeg") or
50                 img.endswith("png")] 
51     
52    
53    
54    print(images)  
55  
56    frame = cv2.imread(os.path.join(image_folder, images[0])) 
57  
58    
59    
60    height, width, layers = frame.shape   
61  
62    video = cv2.VideoWriter(video_name, 0, 1, (width, height))  
63  
64    
65    for image in images:  
66        video.write(cv2.imread(os.path.join(image_folder, image)))  
67      
68    
69    cv2.destroyAllWindows()  
70    video.release()  
71  
72  
73generate_video() 
74
queries leading to this page
images to video pythoncreate video auto thumbnail in pythonpython turn images into videoconvert video pythonmaking video from images pythonvideo to image using pythoncreate images from video using pythonimages to video maker pythonmake a video from images pythoniimages to video pythonpython create video from images ffmpegpython turn video into imagespython video to pnggiven images make video pythoncreate video from photo pythoncreate video from images ptrhonpython create video from imagespython save images as videomake video from bunch pictures using pythonpython combine images to videosave video file from web pythonwrite images to video pythonpython video converter python make videos into clips and imagesvideo to image pythonmake 5 video of image pythoncombine images to video pythonimage to video pythonpython video to imagesmake video from images pythonconvert png images to video pythonpython image to videoshow video on python imageshow to create a video using photos pythonhow to set a video on images in pythonpython make a videocreate a video from iamge and mp4 pythoncreate video from images python3 generate thumbnail from video in pythonpython script to create video from imagesgenerate video from images pythonimages to video using pythonmake video using images in pythonpython display a video from imagesconvert images into video pythonconvert video to jpg pythonpython video from imagespython create images from videocreate a video with images pythonvideo maker from image python codewrite video from images pythonpython read images into videopython convert video to imageshow to make video from images pythonhow to create video from images in pythonpython make video from imageshow to create video from images pythonmake video using image pythongenerate video from text pythonpython images to videomake video from pictures pythonconvert video to images pythonhow to make a video from images in pythonpython how to save image of a video python get image from videobest way to create video from images pythonhow to convert bunch of images to video using pythonpython picture to videomake a video with pythonpython video to audio converterconvert images to video pythonpython generate videomaking a video from images in pythonhow to turn imatges to video in pythonpython make a video from imagesgenrate images from video using pythonmake video from image pythonmake a video of a image in movie pycreate video from images pythonvideo to images pythonget video preview image from video pythoncreate video 2b pythonimages to video in pythoncreate video from images python