Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.58k stars 1.58k forks source link

RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable. #1158

Closed Directory closed 4 years ago

Directory commented 4 years ago

Expected Behavior

not getting an error

Actual Behavior

getting the error in the title

Steps to Reproduce the Problem

be me and try to run from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip

ffmpeg is installed with apt and i can confirm its location in /usr/bin/. additionally ive also executed pip install imageio-ffmpeg in the python virtual environment and it is installed. ive logged platform.python_version() to confirm i was in the 3.8.0 venv. executing a plain interpreter terminal in the venv and trying to import it manually does not resault in an error. only during execution. the execution is in a flask application deployed with gunicorn and nginx.

Specifications

Directory commented 4 years ago

i dont really know what an exe would be doing on linux anyway. but if theres some way to manually point it to /usr/bin/ffmpeg that might do it

tburrows13 commented 4 years ago

I'm not sure why yours isn't working, but you can specifically point it to /usr/bin/ffmpeg by putting the following before importing anything else from moviepy:

from moviepy.config import change_settings
change_settings({"FFMPEG_BINARY": "/usr/bin/ffmpeg"})

or you can manually edit the file config_defaults.py.

Note that this will change in v2.0 (#1109). Either it will be fixed, or you'll have to use an environment variable.

If you'd like help fixing the actual problem of ffmpeg not being auto-detected, please provide the full traceback error that you get.

Directory commented 4 years ago

even that raises the same error.

  File "/home/project/project/server.py", line 14, in <module>
    from moviepy.config import change_settings
  File "/home/project/env/lib/python3.8/site-packages/moviepy/config.py", line 30, in <module>
    FFMPEG_BINARY = get_exe()
  File "/home/project/env/lib/python3.8/site-packages/imageio/plugins/ffmpeg.py", line 49, in get_exe
    return imageio_ffmpeg.get_ffmpeg_exe()
  File "/home/project/env/lib/python3.8/site-packages/imageio_ffmpeg/_utils.py", line 49, in get_ffmpeg_exe
    raise RuntimeError(
RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.
tburrows13 commented 4 years ago

Ok, try this before importing moviepy:

import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "/usr/bin/ffmpeg"
Directory commented 4 years ago

hmm that actually does seem to work. it imports without error. ill get back with a follow up if it actually works works and close the issue

tburrows13 commented 4 years ago

Sure. It’s not a great solution, but maybe it will be properly fixed in v2.0.

pj-mathematician commented 4 years ago

Hi, I am also getting the same error while working in pydroid for Android (similar to linux environment) But I am not able to solve this issue even after the import os. My error-

Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
    start(fakepyfile,mainpyfile)
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
    exec(open(mainpyfile).read(),  __main__.__dict__)
  File "<string>", line 4, in <module>
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/VideoFileClip.py", line 88, in __init__
    self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in __init__
    infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 257, in ffmpeg_parse_infos
    proc = sp.Popen(cmd, **popen_params)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/subprocess.py", line 856, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/subprocess.py", line 1728, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/ffmpeg'

Any help will be appreciated :)

clevrf0x commented 4 years ago

Hi, I am also getting the same error while working in pydroid for Android (similar to linux environment) But I am not able to solve this issue even after the import os. My error-

Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
    start(fakepyfile,mainpyfile)
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
    exec(open(mainpyfile).read(),  __main__.__dict__)
  File "<string>", line 4, in <module>
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/VideoFileClip.py", line 88, in __init__
    self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in __init__
    infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 257, in ffmpeg_parse_infos
    proc = sp.Popen(cmd, **popen_params)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/subprocess.py", line 856, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/subprocess.py", line 1728, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/ffmpeg'

Any help will be appreciated :)

sudo apt install ffmpeg it will fix the issue

cheng321284 commented 3 years ago

Ok, try this before importing moviepy:

import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "/usr/bin/ffmpeg"

It works for me

geyang commented 3 years ago

The issue is that this appears on our HPC system sporadically, during model training.

So even if previous calls worked, this could happen during the same RunTime. There must be something pathological going on.

patellalit1507 commented 3 years ago

it shows RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable. while using on android

please help!

pj-mathematician commented 3 years ago

it shows RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable. while using on android

please help!

@patellalit1507 Termux, apt install ffmpeg

wellpguedes commented 3 years ago

step 1

python3 -m pip install moviepy

step 2

apt install ffmpeg

RAJUL555 commented 3 years ago

step 1

python3 -m pip install moviepy

step 2

apt install ffmpeg

Unfortunately, this doesn't work. Trying to run it on pydroid 3, Android version 12.

ClaudeSerre commented 2 years ago

For those on MAC, if you install ffmpeg with Homebrew, then the path is different, so the code become :

import os

os.environ["IMAGEIO_FFMPEG_EXE"] = "/opt/homebrew/Cellar/ffmpeg/5.1/bin/ffmpeg"

M0nochrome commented 2 years ago

For those in Windows: backward slash and forward slash is not the same. tburrows13 solution does work but you have to use the forward slash for the destination of ffmpeg and not backslashes. If you want to use backslashes then you have to use double backslashes:

import os os.environ["IMAGEIO_FFMPEG_EXE"] = "C:/ffmpeg/bin/ffmpeg.exe"

or

import os os.environ["IMAGEIO_FFMPEG_EXE"] = "C:\\ffmpeg\\bin\\ffmpeg.exe"

(correct for your actual ffmpeg location)

justnpT commented 2 years ago

For those on MAC, if you install ffmpeg with Homebrew, then the path is different, so the code become :

import os

os.environ["IMAGEIO_FFMPEG_EXE"] = "/opt/homebrew/Cellar/ffmpeg/5.1/bin/ffmpeg"

this worked for me, because I have installed ffmpeg with brew

davidbernat commented 2 years ago

For those on MAC, if you install ffmpeg with Homebrew, then the path is different, so the code become : import os os.environ["IMAGEIO_FFMPEG_EXE"] = "/opt/homebrew/Cellar/ffmpeg/5.1/bin/ffmpeg"

this worked for me, because I have installed ffmpeg with brew

Is there an equivalent environmental flag for libraries? Here's why: My homebrew installed into Cellar/ffmpeg/5.1.2.reinstall/... but when that executable runs it still searches for libraries in the /5.1.2/ directory. It seems like an error in an iOS system but this is not my expertise.

dyld[54363]: Library not loaded: /opt/homebrew/Cellar/ffmpeg/5.1.2/lib/libavdevice.59.dylib
  Referenced from: <D4B0734B-405C-3440-A545-A06D935C834D> /opt/homebrew/Cellar/ffmpeg/5.1.2.reinstall/bin/ffmpeg
  Reason: tried: '/opt/homebrew/Cellar/ffmpeg/5.1.2/lib/libavdevice.59.dylib' (no such file),
justnpT commented 2 years ago

For those on MAC, if you install ffmpeg with Homebrew, then the path is different, so the code become : import os os.environ["IMAGEIO_FFMPEG_EXE"] = "/opt/homebrew/Cellar/ffmpeg/5.1/bin/ffmpeg"

this worked for me, because I have installed ffmpeg with brew

Is there an equivalent environmental flag for libraries? Here's why: My homebrew installed into Cellar/ffmpeg/5.1.2.reinstall/... but when that executable runs it still searches for libraries in the /5.1.2/ directory. It seems like an error in an iOS system but this is not my expertise.

dyld[54363]: Library not loaded: /opt/homebrew/Cellar/ffmpeg/5.1.2/lib/libavdevice.59.dylib
  Referenced from: <D4B0734B-405C-3440-A545-A06D935C834D> /opt/homebrew/Cellar/ffmpeg/5.1.2.reinstall/bin/ffmpeg
  Reason: tried: '/opt/homebrew/Cellar/ffmpeg/5.1.2/lib/libavdevice.59.dylib' (no such file),

line in my python file is contains the 5.1.2 as it is the current version (not 5.1): os.environ["IMAGEIO_FFMPEG_EXE"] = "/opt/homebrew/Cellar/ffmpeg/5.1.2/bin/ffmpeg"

I'm not sure what is this "5.1.2.reinstall". Why is there the "reinstall" word ? No idea, it should be clean 5.1.2 IMO

davidbernat commented 2 years ago

@justnpT: Thank you. That is not the question. The name differential is connected to homebrew. The question is whether a separate library flag is in the environment variables.

Maisa-ASM commented 1 year ago

https://github.com/imageio/imageio-ffmpeg : If you're using a Conda environment: the conda package does not include the ffmpeg executable, but instead depends on the ffmpeg package from conda-forge. Install using:

$ conda install imageio-ffmpeg -c conda-forge

Xiaoyun-dev commented 1 year ago

I solved this issue by following the steps

  1. Download the FFmpeg package from the official website.
  2. Choose the Static builds for macOS 64-bit.
  3. add the exe file to directory
  4. set env: import os os.environ["IMAGEIO_FFMPEG_EXE"] = "/Users/.../ffmpeg"
lgjonathan commented 1 year ago

Setting "IMAGEIO_FFMPEG_EXE" didn't work for me.

I had to specify the path in mediapy/__init__.py

class _Config:
  ffmpeg_name_or_path: _Path = r"D:\Programs\ffmpeg\bin\ffmpeg.exe" # insert  ffmpeg.exe path here
  show_save_dir: _Path | None = None
am1994 commented 9 months ago

For Mac users, use this command:

brew install ffmpeg

germansilva45 commented 9 months ago

For Mac users, use this command:

brew install ffmpeg

That made the trick for me. Thank you.

Daryldactyl commented 8 months ago

Hi, I am also getting the same error while working in pydroid for Android (similar to linux environment) But I am not able to solve this issue even after the import os. My error-

Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
    start(fakepyfile,mainpyfile)
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
    exec(open(mainpyfile).read(),  __main__.__dict__)
  File "<string>", line 4, in <module>
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/VideoFileClip.py", line 88, in __init__
    self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in __init__
    infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 257, in ffmpeg_parse_infos
    proc = sp.Popen(cmd, **popen_params)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/subprocess.py", line 856, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/subprocess.py", line 1728, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/ffmpeg'

Any help will be appreciated :)

sudo apt install ffmpeg it will fix the issue

brew install ffmpeg worked for me on mac!

qx commented 7 months ago

os.environ["IMAGEIO_FFMPEG_EXE"] = "/usr/bin/ffmpeg"

How about run in server???

blackaquaindia commented 7 months ago

[Searching Followers: Spotify] Status 201: JSONDecodeError in public_request (url=https://www.instagram.com/ripecekcu/?__a=1&__d=dis) >>> Status 201: JSONDecodeError in public_request (url=https://www.instagram.com/ripecekcu/?__a=1&__d=dis) >>> Status 201: JSONDecodeError in public_request (url=https://www.instagram.com/ripecekcu/?__a=1&__d=dis) >>> Analyzing video file "/storage/emulated/0/Python/joshxantus_3329633938699010847.mp4" Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), main.dict) File "", line 35, in File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.11/site-packages/instagrapi/mixins/video.py", line 424, in video_upload_to_story upload_id, width, height, duration, thumbnail = self.video_rupload( ^^^^^^^^^^^^^^^^^^^ File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.11/site-packages/instagrapi/mixins/video.py", line 170, in video_rupload width, height, duration, thumbnail = analyze_video(path, thumbnail) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.11/site-packages/instagrapi/mixins/video.py", line 899, in analyze_video video = mp.VideoFileClip(str(path)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.11/site-packages/moviepy/video/io/VideoFileClip.py", line 88, in init self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.11/site-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in init infos = ffmpeg_parse_infos(filename, print_infos, check_duration, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.11/site-packages/moviepy/video/io/ffmpeg_reader.py", line 257, in ffmpeg_parse_infos proc = sp.Popen(cmd, **popen_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.11/subprocess.py", line 1028, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.11/subprocess.py", line 1950, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/imageio-ffmpeg'

[Program finished]

I tried ffmpeg also THIS IS FIR ANDROID ON PYDROID

Serjobas commented 7 months ago

I solved this issue by following the steps

  1. Download the FFmpeg package from the official website.
  2. Choose the Static builds for macOS 64-bit.
  3. add the exe file to directory
  4. set env: import os os.environ["IMAGEIO_FFMPEG_EXE"] = "/Users/.../ffmpeg"

works great, thanks mate

blackaquaindia commented 6 months ago

did anyone notice here? we are not talking about WINDOWS or MAC

WE ARE TALKING ABOUT ANDROID SYSTEM

bader1000 commented 6 months ago

A household appliances company in the Netherlands and all of Europe, King Import Export, announces the theft of a container of household appliances and warns customers to beware of purchasing the product without invoices. The invoice must bear the company seal, King Import Export, so as not to be exposed to problems.

Uploading 059aaa29-5a63-4e8b-9546-9d696c1496c9.mov…

e2dc9565-60e4-46ad-ac90-99bb4313a677 ![Uploading da297ad3-6b86-4caa-877d-92cb0f043b25.jpeg…]()

bader1000 commented 5 months ago

I solved this issue by following the steps

  1. Download the FFmpeg package from the official website.

  2. Choose the Static builds for macOS 64-bit.

  3. add the exe file to directory

  4. set env:

    import os

    os.environ["IMAGEIO_FFMPEG_EXE"] = "/Users/.../ffmpeg"

works great, thanks mate