gpt4 book ai didi

python - 使用 ffmpeg-python 将视频分割成图像

转载 作者:行者123 更新时间:2023-12-04 22:46:06 25 4
gpt4 key购买 nike

据我了解ffmpeg-python是Python中的主包,可以直接运行ffmpeg

现在我想拍摄视频并将其帧保存为某些 fps 的单独文件。

有很多命令行方法可以做到这一点,例如ffmpeg -i video.mp4 -vf fps=1 img/output%06d.png described here

但我想用 Python 来做。还有解决办法[1] [2]使用 Python 的 subprocess 调用 ffmpeg CLI,但它对我来说看起来很脏。

有什么方法可以使用 ffmpeg-python 实现吗?

最佳答案

以下对我有用:

ffmpeg
.input(url)
.filter('fps', fps='1/60')
.output('thumbs/test-%d.jpg',
start_number=0)
.overwrite_output()
.run(quiet=True)

关于python - 使用 ffmpeg-python 将视频分割成图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64143387/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com