python - FileNotFoundError: [WinError 2] 使用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()```
解决方案
您看到的 WindowsError 不是指视频文件,而是指 ffmpeg 可执行文件本身。对 subprocess.call 的调用不知道 File.mp4 是您传递的文件名。Windows 知道第一个参数应该是一个可执行文件,并向解释器报告它找不到它。
仔细检查 ffmpeg 是否可以在您的解释器运行的环境中执行。您可以将其添加到您的 PATH 或指定 ffmpeg.exe 的完整路径。
推荐阅读
- android - 未收到推送通知:com.google.android.gcm.server.InvalidRequestException:HTTP 状态代码:400
- java - 如何使用 spring rest 服务/spring boot 下载 Excel
- gpflow - 泊松似然的 GPflow 预测均值/方差
- reactjs - 我应该使用什么 babel 插件来正确工作 react-dnd?
- spring-boot - 无法在 java 中使用 DocumentClient 从 cosmos 中删除文档
- c# - 如何显示一个消息框,询问用户是否真的要退出 cmd 窗口?
- android - 导航组件问题和 TextInputLayout 错误
- google-cloud-data-fusion - 无法将 Excel 文件从 Google Cloud Storage 加载到 Google Data Fusion
- sqlite - 使用子表从父表中获取值
- python - 根据 Firestore 更改触发 Cloud Function