Video from images with variable frame rate

别说谁变了你拦得住时间么 提交于 2021-02-11 16:30:02

问题


I'd like to create a video from still images, but instead of using a static FPS, I have a specific timestamp for each image (the images are not exactly evenly spaced in time).

How could I go about doing this?

My current code, with a static FPS, is as follows

import cv2
import os

image_folder = '/Users/alex/Dropbox/Apps/CCTV-AE/rasp2/saved/movies/'
video_name = '/Users/alex/Dropbox/Apps/CCTV-AE/rasp2/saved/movies/video.avi'

images = sorted([img for img in os.listdir(image_folder) if img.endswith(".jpg")])

frame = cv2.imread(os.path.join(image_folder, images[0]))
height, width, layers = frame.shapevideo = cv2.VideoWriter(video_name, 0, 9, (width,height))

for image in images:
    print(os.path.join(image_folder, image))
    video.write(cv2.imread(os.path.join(image_folder, image)))

cv2.destroyAllWindows()
video.release()

来源:https://stackoverflow.com/questions/62521133/video-from-images-with-variable-frame-rate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!