You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

使用ffmpeg-python调用ffmpeg.run()遇FileNotFoundError问题咨询

Fixing FileNotFoundError with ffmpeg-python's run() Method

Hey there, let's break down what's causing this error and how to fix it quickly.

The Root Cause

That FileNotFoundError isn't about your vid.mp4 file—it means your system can't locate the actual ffmpeg executable. Remember, ffmpeg-python is just a wrapper library; it doesn't include the ffmpeg tool itself. You need to have ffmpeg installed on your system and accessible to Python.

Step-by-Step Solutions

1. Install the ffmpeg Binary First

Grab a Windows build of ffmpeg from its official site (pick the version matching your system architecture—32-bit or 64-bit). Once downloaded:

  • Extract the zip file to a folder (e.g., C:\ffmpeg)
  • Inside that folder, you’ll find a bin directory containing ffmpeg.exe, ffprobe.exe, and other related tools.

2. Make Python Find ffmpeg (Two Options)

Option A: Add ffmpeg to System PATH (Permanent Fix)

This lets any program on your system access ffmpeg:

  • Right-click "This PC" → "Properties" → "Advanced System Settings" → "Environment Variables"
  • Under "System Variables", find the Path variable, click "Edit"
  • Click "New" and paste the full path to the bin folder (e.g., C:\ffmpeg\bin)
  • Save changes and restart your Python IDE/command prompt—this ensures the new PATH takes effect.
Option B: Specify ffmpeg Path Directly in Code (Temporary/Project-Specific Fix)

If you don’t want to modify system PATH, you can tell ffmpeg-python exactly where to find the executable:

import ffmpeg

# Option 1: Specify path when calling run()
videoInput = ffmpeg.input('vid.mp4')
videoOutput = videoInput.output('test.avi')
videoOutput.run(cmd='C:/ffmpeg/bin/ffmpeg.exe')  # Replace with your actual path

# Option 2: Set the executable globally at the start
ffmpeg.EXECUTABLE = 'C:/ffmpeg/bin/ffmpeg.exe'
videoInput = ffmpeg.input('vid.mp4')
videoOutput = videoInput.output('test.avi')
videoOutput.run()

Quick Validation

To confirm ffmpeg is set up correctly, open a command prompt and run:

ffmpeg -version

If it shows the ffmpeg version info, you’re good to go—re-run your Python code and the error should be gone.

Bonus: Double-Check Your Input File Path

While the main issue is ffmpeg itself, it’s worth confirming your vid.mp4 is in the correct directory. If you’re unsure, use an absolute path for the input:

videoInput = ffmpeg.input('C:/Users/geral/Desktop/PythonPrograms/vid.mp4')

内容的提问来源于stack exchange,提问作者Gerald Leese

火山引擎 最新活动