You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Python压缩视频时遇'ffmpeg可执行文件未找到'错误,求解决

Fixing "Executable 'ffmpeg' not found" Error with ffmpy in Python

Hey there! That error pops up because ffmpy is just a Python wrapper for ffmpeg—it doesn’t include the actual ffmpeg tool itself. Let’s walk through how to fix this step by step:

1. Install ffmpeg on your system

First, you need to have ffmpeg installed locally. Here’s how to do it for different operating systems:

  • Windows: Download the latest build from the official ffmpeg site, extract the zip file, then add the bin folder (where ffmpeg.exe lives) to your system’s PATH environment variable. Alternatively, if you use Chocolatey, run choco install ffmpeg in Command Prompt.
  • macOS: Use Homebrew—run brew install ffmpeg in Terminal.
  • Linux (Debian/Ubuntu): Run sudo apt update && sudo apt install ffmpeg in Terminal. For Fedora, use sudo dnf install ffmpeg.

2. Verify ffmpeg is accessible

Open a new terminal/Command Prompt window and run:

ffmpeg -version

If this outputs ffmpeg’s version info, you’re good to go. If not, double-check that the ffmpeg path is added to your system’s PATH.

3. Update your Python code (and fix the incomplete line!)

Your original code cuts off at ff = ffmpy...—here’s the full corrected version, plus an optional fix if ffmpeg still isn’t found:

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}

# If ffmpeg is in PATH, this works:
ff = ffmpy.FFmpeg(inputs=inp, outputs=outp)

# If it's NOT in PATH, specify the full path to ffmpeg:
# ff = ffmpy.FFmpeg(
#     executable='/full/path/to/ffmpeg',  # e.g., 'C:/ffmpeg/bin/ffmpeg.exe' on Windows
#     inputs=inp,
#     outputs=outp
# )

ff.run()

Why this works

By installing ffmpeg and making sure it’s accessible via your system’s PATH, ffmpy can find the executable it needs to run the compression. If PATH isn’t set up correctly, explicitly pointing to the ffmpeg binary in your code will bypass that issue.

内容的提问来源于stack exchange,提问作者Ahmed Mohamed

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:00:38