Python 中如何在内存中优雅地提取视频帧?

查看 247|回复 21
Anarchy   
用 pyav 很简单的
Anarchy   
@Anarchy 给个例子:
with av.open(url, options=options) as container:
video = container.streams.video[0]
for i,t in enumerate([10,15,20,25,30]):
container.seek(int(t/video.time_base)+video.start_time, backward=True, stream=video)
frame = next(container.decode(video))
frame.to_image().save(target_folder/f'frame{i}.png')
您需要登录后才可以回帖 登录 | 立即注册

返回顶部