参考:https://github.com/dmlc/decord
https://www.bilibili.com/video/av843220125/
****安装: pip install decord
1、读取使用
from decord import VideoReader
from decord import cpu, gpu
vr = VideoReader('D:\clip4clip\msvd_data\YouTubeClips\_1vy2HIN60A_32_40.avi', ctx=cpu(0))
print('video frames:', len(vr))
加载指定帧
frames = vr.get_batch([1, 3, 5, 7, 9])
print(frames.shape)
2、保存帧为图片
plt.axis(‘off’) 去掉坐标
bbox_inches=‘tight’ 去掉左右空白
frame1 = vr[1].asnumpy()
from matplotlib import pyplot as plt
plt.imshow(frame1)
plt.axis('off')
plt.savefig("111.jpg", bbox_inches='tight')