gpt4 book ai didi

python - 如何在 python 脚本中使用这个 FFMPEG 命令?

转载 作者:行者123 更新时间:2023-12-04 22:54:56 28 4
gpt4 key购买 nike

我试图从视频中每秒提取一帧 , 在命令行上使用此命令使用 ffmpeg ffmpeg -i input_file.mp4 -r 1 %04d.jpg
我可以在命令行上使用 ffmpeg 来完成这项任务。
但是我想在 python 脚本中使用相同的命令,我该怎么做,代码应该是什么?
我对这个领域很陌生。

最佳答案

你可以吗os.system或者您可以使用 ffmpeg library ,但由于它只是一个命令,我只会使用 os.system方法

# importing os module  
import os

input_file = 'something.mp4' # You should enter the file's path here
# Using fstring for variable file name
# Command to execute
# Using Windows OS command
cmd = f'ffmpeg -i {input_file} -r 1 %04d.jpg'
# Using os.system() method
os.system(cmd)

关于python - 如何在 python 脚本中使用这个 FFMPEG 命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62792832/

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