[英]How do I use this FFMPEG command in python script?
我正在嘗試從視頻中每秒提取一幀,在命令行上使用此命令使用 ffmpeg ffmpeg -i input_file.mp4 -r 1 %04d.jpg
我可以在命令行上使用 ffmpeg 來完成這項任務。
但是我想在 python 腳本中使用相同的命令,我該怎么做,代碼應該是什么? 我對這個領域很陌生。
你可以使用os.system
或者你可以使用ffmpeg 庫,但由於它只是一個命令,我只會使用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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.