Home why can't I get all different sized images in the video using opencv python?
Reply: 0

why can't I get all different sized images in the video using opencv python?

user1007
1#
user1007 Published in May 26, 2018, 11:41 pm

I want to create video from images using opencv in python. But unfortunately I found that the video doesn't contain all images. Then I check the size and found all images size is not same. So I resized all images before writing it into video file. Then I got error while opening the video file showing "Could not demultiplex stream". What am I missing here? please correct me.

here is my code:

import cv2
import numpy as np
import os
image_list=os.listdir(os.getcwd())
img=[]
i=0
for filename in image_list:
    if(filename.endswith(".jpg")):
        img.append(filename)
        i+=1
frame=cv2.imread(img[0])
height,width,layers=frame.shape
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video=cv2.VideoWriter('video.avi',fourcc,1,(width,height))

for file in img:

    image=cv2.imread(file)
    resized=cv2.resize(image,(960,720)) #for my image list lowest size.
    print(file,resized.shape)
    video.write(resized)

video.release()
cv2.destroyAllWindows()
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305923 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO