静止画を動画に変換 opencv3.4.3 python3.6.7 Raspberry Pi Zero W
連番でない静止画74枚(1296×972, 72枚x約650KB=計49.2MB)→動画 v.mp4(1024×768, 779.2KB) へ変換OK
import cv2,glob codec= cv2.VideoWriter_fourcc('m','p','4','v') #codec MP4V v= cv2.VideoWriter('v.mp4',codec,5.0,(1024,768)) #filename,codec,fps,framesize,iscolor #video= cv2.VideoWriter('v.mp4',codec,10.0,(1296,972)) #filename,codec,fps,framesize,iscolor F= glob.glob('/home/pi/cam/181127/*.jpg') F= sorted(F) for x in F: #print(x) f= cv2.imread(x) f= cv2.resize(f,(1024,768)) v.write(f) v.release() print('done')