系统找不到用ffmpeg指定的文件 [英] The system cannot find the file specified with ffmpeg

查看:1298
本文介绍了系统找不到用ffmpeg指定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用ffmpeg模块编辑视频文件的过程中,我使用了子过程模块

In the process of using the ffmpeg module to edit video files i used the subprocess module

代码如下:

#trim bit

import subprocess
import os
seconds = "4"
mypath=os.path.abspath('trial.mp4')
subprocess.call(['ffmpeg', '-i',mypath, '-ss', seconds, 'trimmed.mp4'])

错误消息:

Traceback (most recent call last):
  File "C:\moviepy-master\resizer.py", line 29, in <module>
    subprocess.call(['ffmpeg', '-i',mypath, '-ss', seconds, 'trimmed.mp4'])
  File "C:\Python27\lib\subprocess.py", line 168, in call
    return Popen(*popenargs, **kwargs).wait()
  File "C:\Python27\lib\subprocess.py", line 390, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

在查找了类似的问题之后,我了解到该模块无法选择视频文件,因为它需要其路径,因此我采用了绝对路径.但是尽管如此,错误仍然出现. 保存该代码的模块和视频文件trial.mp4在同一文件夹中.

After looking up similar problems i understood that the module is unable to pick the video file because it needs its path, so i took the absolute path. But in spite of that the error still shows up. The module where this code was saved and the video file trial.mp4 are in the same folder.

推荐答案

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

The WindowsError you see does not refer to the video file but to the ffmpeg executable itself. The call to subprocess.call has no idea that trimmed.mp4 is a filename you are passing. Windows knows that the first parameter ought to be an executable file and reports back to the interpreter that it can't find it.

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

Double-check that ffmpeg can be executed in the environment your interpreter is running in. You may either add it to your PATH or specify the full path to ffmpeg.exe.

这篇关于系统找不到用ffmpeg指定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆