The system cannot find the file specified with ffmpeg

Viewed 12171

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

The code is as follows:

#trim bit

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

Error message:

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

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.

6 Answers

None of the above answers worked for me.

I got it working, by opening Anaconda Navigator > CMD prompt.

conda install ffmpeg

Most of the answers didn't work. Here is what worked for me using conda env:

pip uninstall ffmpeg-python
conda install ffmpeg
pip install ffmpeg-python

Just the conda installation gives library not found error. Didn't try uninstalling conda library either but this works.

This answer is directed at Windows users of the ffmpeg-python library since this question is the first search result for a stricter instance of the same issue.

Adding on to user2722968's answer because neither of the existing answers solved the problem for me.

As of this post, ffmpeg-python uses subprocess.Popen to run ffmpeg. Per this issue, subprocess does not look in Path when resolving names, so even if FFmpeg is installed and in your Path and you can run it from CMD/PowerShell, ffmpeg-python may not be able to use it.

My solution was to copy ffmpeg.exe into the Python environment where python.exe is. This workaround seems far from ideal but it seems to have solved the problem for me.

I had the same issue! And I FOUND A SOLUTION.

I realised, viewing all these answers that I need to install ffmpeg. I tried 'pip install ffmpeg' but that didn't work. What worked was copying the ffmpeg.exe file to the folder that python.exe is in. Thats what someone up here mentioned. Thank you! To download the ffmpeg.exe file, download the zip file from https://github.com/GyanD/codexffmpeg/releases/tag/2022-06-06-git-73302aa193

First Uninstall all pip libraries

pip uninstall ffmpeg
pip uninstall ffmpeg-python

Then install using conda

conda install fmpeg
Related