如何使用 ffmpeg 从视频中获取前 16 个成名?

How to get first 16 fames from a video using ffmpeg?

我有一个 mp4 视频文件(时长 5 秒),它有 125 帧。我需要将前 16 个连续帧 提取到一个文件夹中。能把提取前16帧的代码放上来吗?

我试过了-

cmd = 'ffmpeg -i {} -frames:v 16 {}/%d.png'.format('/content/drive/MyDrive/MTP/train/X/X0.mp4', '/content/drive/MyDrive/MTP/sample') 
subprocess.call(cmd, shell = True)

成功了。

使用-frames:v / -vframes:

ffmpeg -i input.mp4 -frames:v 16 output_%02d.png

另见 image muxer documentation