Jules Dany
Jules Dany

Reputation: 13

FFMPEG - [WinError 2] The system cannot find the file specified

I'm having an issue using the FFmpeg package.

Here's my code :

import ffmpeg_streaming

from ffmpeg_streaming import Formats, Bitrate, Representation, Size

_360p  = Representation(Size(640, 360), Bitrate(276 * 1024, 128 * 1024))
_480p  = Representation(Size(854, 480), Bitrate(750 * 1024, 192 * 1024))
_720p  = Representation(Size(1280, 720), Bitrate(2048 * 1024, 320 * 1024))

hls = video.hls(Formats.h264())
hls.representations(_360p, _480p, _720p)
hls.output('C:/Users/juled/Videos/testStreaming')

Quite simple as you can see, found it on the web.

And here's the error message I have:

Traceback (most recent call last):
  File "C:\Users\juled\OneDrive\Bureau\PACT\streamingMultimedia\streaming.py", line 50, in <module>
    hls.output('C:/Users/juled/Videos/testStreaming')
  File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\site-packages\ffmpeg_streaming\_media.py", line 93, in output
    self.run(ffmpeg_bin, monitor, **options)
  File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\site-packages\ffmpeg_streaming\_media.py", line 121, in run
    asyncio.run(self.async_run(ffmpeg_bin, monitor, **options))
  File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\asyncio\runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\asyncio\base_events.py", line 583, in run_until_complete
    return future.result()
  File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\site-packages\ffmpeg_streaming\_media.py", line 112, in async_run
    self._run(ffmpeg_bin, monitor, **options)
  File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\site-packages\ffmpeg_streaming\_media.py", line 105, in _run
    with Process(self, command_builder(ffmpeg_bin, self), monitor, **options) as process:
  File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\site-packages\ffmpeg_streaming\_process.py", line 58, in __init__
    self.process = _p_open(commands, **options)
  File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\site-packages\ffmpeg_streaming\_process.py", line 29, in _p_open
    return subprocess.Popen(shlex.split(commands), **options)
  File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\subprocess.py", line 1207, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

I've been checking every file quoted in the error message, but only one of them is "my" code, the others are FFmpeg and Python libraries codes.

I'm using IDLEX for Python 3.7.6 on Windows by the way.

I've tried to change some of the FFmpeg library code, especially where subprocess.Popen appears, by putting a shell=True in the parameters. New Error Message, different this time.

I've added FFmpeg to the PATH, no change.

I've reinstalled FFmpeg to be sure, but no change. I'm using this version: python-ffmpeg-video-streaming-0.1.14.

Do any of you have a solution I could try ?

Oh and a friend has the same issue on MAC.

Upvotes: 1

Views: 4267

Answers (1)

K.Cl
K.Cl

Reputation: 1783

This is a PATH environment variable issue. Based on this link, you could try:

import os
path = 'the path you want'
os.environ['PATH'] += ';'+path

to add the path to ffmpeg.exe to your system path (and also to check if your python instance is really looking at the correct path), and you can also change pythonpath,

import sys
sys.path.insert(0,'path/to/ffmpeg')

Note how these two are totally different. However, I find that the easiest way with programs like ffmpeg, which are self-contained executables, that you can just copy them to the working directory of your script and then run it, which is what solved your problem.

Upvotes: 1

Related Questions