把图片存成视频 python

tips:

1.保存的图片大小一定要一样

2.图像做好是标准的视频格式大小

3.图片要和视频size一样大小

代码如下

# -*- coding:utf8 -*-
import os
import cv2
import numpy as np


import cv2.cv as cv
path = '/home/m/mycode/cv'
filelist = os.listdir(path)
total_num = len(filelist)


video=cv2.VideoWriter("VideoTest.avi", cv2.cv.CV_FOURCC('I','4','2','0'), 1, (1280,1024))
for item in filelist:
    if item.endswith('.jpg'):
        item='/home/m/mycode/cv/'+item
        img1 = cv2.imread(item)
        print item


        video.write(img1)
        cv2.imshow("Image", img1)
        key=cv2.waitKey(100)


video.release()
cv2.destroyAllWindows()


你可能感兴趣的:(opencv,python)