how to resolve error FileNotFoundError: [WinError 2] The system cannot find the file specified when using ffmpeg-python?

how to resolve error FileNotFoundError: [WinError 2] The system cannot find the file specified when using ffmpeg-python?

我正在尝试使用 ffmprg 将视频和音频文件合并在一起,但我一直收到此错误

错误:

Traceback (most recent call last):
  File "C:\Users\Geo\youtubedownloader\test.py", line 9, in <module>
    ffmpeg.concat(video,audio, v=1 , a=1).output("C:/Users/Geo/output_video/mergedretweett.mp4/").run()
  File "C:\Users\Geo\AppData\Local\Programs\Python\Python39\lib\site-packages\ffmpeg\_run.py", line 313, in run
    process = run_async(
  File "C:\Users\Geo\AppData\Local\Programs\Python\Python39\lib\site-packages\ffmpeg\_run.py", line 284, in run_async
    return subprocess.Popen(
  File "C:\Users\Geo\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\Geo\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1416, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

代码:



video = ffmpeg.input("C:/Users/Geo/File.mp4")

audio = ffmpeg.input("C:/Users/Geo/File_audio.mp4")


ffmpeg.concat(video,audio, v=1 , a=1).output("C:/Users/Geo/output_video/outputvideo.mp4").run()```


您看到的Windows错误不是指视频文件,而是指 ffmpeg 可执行文件本身。对 subprocess.call 的调用不知道 File.mp4 是您传递的文件名。 Windows 知道第一个参数应该是一个可执行文件并向解释器报告它找不到它。

仔细检查 ffmpeg 是否可以在您的解释器 运行 所在的环境中执行。您可以将其添加到您的 PATH 或指定 ffmpeg.exe.[=10= 的完整路径]

我也遇到了同样的错误。
然后查了一下,发现需要ffmpeg
当我从这段代码安装它时:

conda install -c conda-forge ffmpeg

(对于 anaconda),我的问题得到解决。