图片合成视频

图片合成视频

首页休闲益智合成小宇宙更新时间:2024-08-01

import cv2 import os def images_to_video(image_folder, video_name, fps): images = [img for img in os.listdir(image_folder) if img.endswith(".png") or img.endswith(".jpg") or img.endswith(".jpeg")] #images.sort() frame = cv2.imread(os.path.join(image_folder, images[0])) height, width, layers = frame.shape video = cv2.VideoWriter(video_name, cv2.VideoWriter_fourcc(*'XVID'), fps, (width, height)) for image in images: video.write(cv2.imread(os.path.join(image_folder, image))) cv2.destroyAllWindows() video.release() image_folder = 'C:/Users/29269/Desktop/sm/' # 图片文件夹路径 video_name = 'C:/Users/29269/Desktop/sm/output.mp4' # 输出视频文件名 后缀可以是 .avi fps = 7 #帧率 images_to_video(image_folder, video_name, fps)

查看全文
大家还看了
也许喜欢
更多游戏

Copyright © 2024 妖气游戏网 www.17u1u.com All Rights Reserved