首页 > 解决方案 > 在 python 中找不到可执行的“ffmpeg”

问题描述

我正在尝试使用 python 压缩视频,但是有一个错误,我无法理解如何解决它,所以你能帮我吗?我附上了一张图片,代码在这里输入图片描述

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

标签: pythonffmpeg

解决方案


的包依赖项之一ffmpyffmpeg. 实际上ffmpyffmpeg. 要解决您的问题,请使用 pip 安装ffmpeg.


推荐阅读