def make_thumbnail(video, db):
indices = [int(n * video.num_frames) for n in [0.1, 0.35, 0.60, 0.85]]
table = db.table(video.path)
frames = [f[0] for _, f in table.load([1], rows=indices)]
img = make_montage(len(frames), iter(frames), frame_width=150, frames_per_row=2)
run('mkdir -p assets/thumbnails')
cv2.imwrite('assets/thumbnails/{}.jpg'.format(video.id), cv2.cvtColor(img, cv2.COLOR_RGB2BGR))
评论列表
文章目录