Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: "RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work" #21

Open
Collab-with-Rajibul opened this issue Dec 14, 2024 · 7 comments
Labels
question Further information is requested

Comments

@Collab-with-Rajibul
Copy link

C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\pydub\utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)

The above error is encountered even if I just import the module "markitdown"

@SH4DOW4RE
Copy link
Contributor

Do you have ffmpeg installed ?

@gagb gagb added the question Further information is requested label Dec 14, 2024
@SH4DOW4RE
Copy link
Contributor

SH4DOW4RE commented Dec 14, 2024

After looking into installed packages, pydub has that error if you don't have a path to either ffmpeg or avconv in your system's PATH variable

Here's the code from pydub if you're curious:

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


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"

@Collab-with-Rajibul
Copy link
Author

Collab-with-Rajibul commented Dec 15, 2024

Do you have ffmpeg installed ?

I am using this for conversion of pdf documents only and transcriptions are not required for my application. Do I still have to install ffmpeg?

@SH4DOW4RE
Copy link
Contributor

SH4DOW4RE commented Dec 15, 2024

After looking into both the code of pydub and markitdown, I saw that pydub checks for either ffmpeg or avconv when it is first imported, and the code inside markitdown only checks if the module ins't found, as that cannot be as it is installed as a dependency, I think it should instead check for if either the module is not found (just in case) as well as a RuntimeWarning error coming from pydub, as that would indicate that pydub cannot convert mp3, and would put the variable IS_AUDIO_TRANSCRIPTION_CAPABLE to false, not running anymore pydub related code.

TLDR: Either you uninstall pydub if you don't need it. Or you install either ffmpeg or avconv to remove that error from pydub

If markitdown devs want, I can make a pull request to try and find a fix for this issue
Made one already just in case

@caesarllj
Copy link

Audio Transcript:

Error. Could not transcribe this audio.

@SH4DOW4RE
Copy link
Contributor

What did you try before getting this error ?

@SH4DOW4RE
Copy link
Contributor

The Pull Request got accepted. Can you please try again on the new version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants