Soundscape_to_panorama / tensor2video.py
Staty's picture
Upload 2 files
0fc624e verified
raw
history blame
610 Bytes
import os
import imageio
from PIL import Image
# 设置生成的视频文件名和路径
filename = 'output.mp4'
filepath = os.path.join(os.getcwd(), filename)
print(filepath)
# 读取所有 PNG 图片
images = []
for file_name in sorted(os.listdir("./out2/")):
if file_name.endswith('.jpg'):
images.append(Image.open("./out2/"+file_name))
import numpy as np
# 将图片转换为视频
fps = 25 # 每秒钟30帧
with imageio.get_writer(filepath, fps=fps) as video:
for image in images:
frame = np.array(image.convert('RGB'))
video.append_data(frame)