主要用到opencv,把某一天上午6:00-10:00的每隔10s的1440张照片制作成了视频动画。(制作耗时很短)
import cv2 as cv
def export_video(date): # '1221','1222',etc
img = cv.imread('Time_Panel/{}/6-0-0.png'.format(date))
imgInfo = img.shape
size = (imgInfo[1],imgInfo[0])
four_cc = cv.VideoWriter_fourcc(*'XVID')
videowriter = cv.VideoWriter(PLOT +'Time_Panel/{}.mp4'.format(date),four_cc,5,size)
for hour in [6,7,8,9]:
for min in range(60):
for sec in range(0,60,10):
img = cv.imread('Time_Panel/{}/{}-{}-{}.png'.format(date,hour,min,sec))
videowriter.write(img)
videowriter.release()
cv.destroyAllWindows()
export_video('1221')
最后导出mp4视频,可以播放
opencv中文官方文档