Python视频转图像序列,图像序列转视频

import skvideo.io
import numpy as np 

videogen = skvideo.io.vreader('/home/shuai/python_test/origin.mp4',num_frames=30)

i = 0
for frame in videogen:
    skvideo.io.vwrite("originframe{:0>3d}.png".format(i), frame) 
    i = i + 1


frame0 = skvideo.io.vread('/home/shuai/python_test/originframe000.png')
# frame1 = skvideo.io.vread('/home/shuai/python_test/originframe001.png')
T, M, N, C = frame0.shape

outputdata = np.random.random(size=(30, M, N, C)) * 255
outputdata = outputdata.astype(np.uint8)
for a in range(30):
    outputdata[a] = skvideo.io.vread('/home/shuai/python_test/originframe{:0>3d}.png'.format(a))
# outputdata[0] = frame0
# outputdata[1] = frame1

skvideo.io.vwrite("outputvideo.mp4", outputdata)

你可能感兴趣的:(Python视频转图像序列,图像序列转视频)