我正在尝试使用python压缩视频,但是有一个错误,我无法理解如何解决它,所以你能帮我吗? 我附上了一张图片和代码enter image description here
import ffmpy
input_name = input("Enter name of input file: ")
crf = int(input("Enter constant rate factor between 18 and 24: "))
output_name = input("Enter output file name: ")
inp = {input_name: None}
outp = {output_name: '-vcodec libx264 -crf %d'%crf} #video codec and compression rate
ff = ffmpy.FFmpeg(inputs=inp, outputs=outp) #creates an FFmpeg object
print(ff.cmd) #just to verify that it produces the correct ffmpeg command
ff.run() #does the compression
print("done!")
跑步,我得到了
Enter name of input file: newproject.mp4
Enter constant rate factor between 18 and 24: 20
Enter output file name: "com.mp4"
ffmpeg -i newproject.mp4 -vcodec libx264 -crf 20 com.mp4
Traceback (most recent call last):
File "E:/ahmed/Installed Programs/PyCharm/SelecedTopics/bonus2.py", line 10, in <module>
ff.run() #does the compression
File "E:\ahmed\Python\Anaconda\lib\site-packages\ffmpy.py", line 99, in run
raise FFExecutableNotFoundError("Executable '{0}' not found".format(self.executable))
ffmpy.FFExecutableNotFoundError: Executable 'ffmpeg' not found
Process finished with exit code 1
答案 0 :(得分:1)
ffmpy
的包依赖项之一是 ffmpeg
。实际上,ffmpy
是 ffmpeg
的包装器。要解决您的问题,请使用 pip 安装 ffmpeg
。