3b1b / manim

Animation engine for explanatory math videos
MIT License
61.81k stars 5.75k forks source link

'Couldn't find ffmpeg or avconv' despite having installed them? #1491

Open aflockdescends opened 3 years ago

aflockdescends commented 3 years ago

Hello, I think I initially posted this in the wrong place, please let me know if this isn't where this belongs. I'm trying to get started with Manim and am having trouble with the set up.

Context

I installed ffmpeg via "brew install ffmpeg" in Terminal, and also installed libav with "brew install libav". When I put "ffmpeg" or "avconv" in Terminal, all appears to be fine. ffmpeg is in /usr/local/Cellar.

I initially installed manim via "pip3 install manim". Again, seems to be fine upon check. I also did manimgl. I ran into the issue below so then tried a different route:

git clone https://github.com/3b1b/manim.git
cd manim
pip install -e .
manimgl example_scenes.py OpeningManimExample

The example seems to work (sort-of; LaTeX seemed buggy).

Problem

Anyway, I opened up Python using IDLE, and pasted the following 'test' code:

from manim import *

class SquareToCircle(Scene):
def construct(self):
circle = Circle()
circle.set_fill(PINK, opacity=0.5)
self.play(Create(circle))

Error:

Warning (from warnings module):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pydub/utils.py", line 170
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work 

Environment

OS System: macOS Catalina 10.15.7 manim version: installed here: https://github.com/3b1b/manim.git Python version: 3.9.1

WyattBlue commented 3 years ago

Do you have ffmpeg on your PATH?

running which ffmpeg should output:

/usr/local/bin/ffmpeg
aflockdescends commented 3 years ago

Do you have ffmpeg on your PATH?

running which ffmpeg should output:

/usr/local/bin/ffmpeg

Yep that is what I get if I run which ffmpeg.

WyattBlue commented 3 years ago

Yep that is what I get if I run which ffmpeg.

That's good to hear. I did some more digging and I found that scene_file_writer.py imports Audiosegment from pydub in the second line. If you're only exporting video, you might not need this import and you can comment that out.

Otherwise, look into the which("ffmpeg") function pydub uses, it's throwing an error because it's not returning anything.

'''pydub/utils.py'''

def get_encoder_name():
    """
    Return enconder default application for system, either avconv or ffmpeg
    """
    if which("avconv"):
        return "avconv"
    elif which("ffmpeg"):
        return "ffmpeg"
    else:
        # should raise exception
        warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
        return "ffmpeg"

Try running this python.


import os

def which(program):
    """
    Mimics behavior of UNIX which command.
    """
    # Add .exe program extension for windows support
    if os.name == "nt" and not program.endswith(".exe"):
        program += ".exe"

    envdir_list = [os.curdir] + os.environ["PATH"].split(os.pathsep)

    for envdir in envdir_list:
        program_path = os.path.join(envdir, program)
        if os.path.isfile(program_path) and os.access(program_path, os.X_OK):
            return program_path

print(which("ffmpeg"))

I got:

/usr/local/bin/ffmpeg
[Finished in 0.1s]
aflockdescends commented 3 years ago

Try running this python.

I got:

/usr/local/bin/ffmpeg
[Finished in 0.1s]

Aha interesting. I get 'None' if run from IDLE. I figured out today that it all works fine if I run from Terminal (and indeed then the code you sent returns the path you got). But if I run from within the IDE I use ('IDLE Shell 3.9.1'), I get None for this test, and the Error above if I try anything with manim.

So I guess this is an issue with IDLE. If you know how to fix that then brilliant, but no worries if not since I can just run from Terminal instead.

nchecherina commented 3 years ago

hi! i've been using manimCE and ffmpeg isn't working for me. i installed it a few times and created a path for it, but it still isn't working for some reason? this is what shows up: FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg' and then: PermissionError: [Errno 13] Permission denied: 'ffmpeg' could someone pls tell me what they did? tysm!

Yagna24 commented 2 years ago

hi! i've been using manimCE and ffmpeg isn't working for me. i installed it a few times and created a path for it, but it still isn't working for some reason? this is what shows up: FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg' and then: PermissionError: [Errno 13] Permission denied: 'ffmpeg' could someone pls tell me what they did? tysm!

install ffmpeg using anaconda prompt using : conda install -c main ffmpeg

eikku commented 4 months ago

I have been struggling with this for days, tried different installations what not and realised that all works fine when running python on terminal, but vscode cannot find ffprobe or ffpmeg even though I explicitly define them.