图片转成视频

图片转成视频

import os
import cv2
import numpy as np
import scipy.misc
from pathlib import Path

path = './film_frame/'
filelist = os.listdir(path)

fps = 24 #视频每秒24帧
# size = (416, 320) #需要转为视频的图片的尺寸
size = (1376, 832)
#可以使用cv2.resize()进行修改

video = cv2.VideoWriter("film_frame.mp4", cv2.VideoWriter_fourcc('I', '4', '2', '0'), fps, size)
#视频保存在当前目录下

for i in range(5992, 6515):
	# item = path + item
	my_file = Path(path+str(i)+'.png')
	if my_file.is_file(): 
		img = scipy.misc.imread(my_file)
		video.write(img)

video.release()
cv2.destroyAllWindows()

你可能感兴趣的:(技术,深度学习,深度学习通用代码,深度学习)