1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How do I bundle ffmpeg with my PyInstaller --onefile executable correctly?

Discussão em 'Python' iniciado por Stack, Setembro 8, 2025.

  1. Stack

    Stack Membro Participativo

    I’ve been struggling for a while to package my Python script with PyInstaller into a standalone executable, but the main blocker seems to be getting ffmpeg and yt_dlp bundled and accessible in the final build.

    My Goal

    I want a true standalone executable created with PyInstaller (--onefile) that includes ffmpeg so that it works out-of-the-box on any machine, without requiring users to install ffmpeg or set up environment variables.

    Question

    How can I properly bundle ffmpeg into my PyInstaller build?

    Has anyone successfully bundled ffmpeg with --onefile and can share the working approach? Or point me in the right direction?

    Additional Info

    OS: Windows Python version: Python 3.13.0 PyInstaller version: 6.15.0 ffmpeg version: 2025-09-01-git-3ea6c2fe25-full_build-www.gyan.dev (...) built with gcc 15.2.0

    i tried Running:

    pyinstaller --onefile discordmusicbot.py

    i've tried with hiddenimports, .spec file i got it to run but for some reason ffmpeg never seemed to work even packing it as .exe datas.append(('ffmpeg.exe', '.'))

    Adding ffmpeg to PATH on my development machine, also doesn't work, but would also defeat the purpose of making a standalone executable. I also know about the .spec placing it in the wrong directory, but moving it didnt help. i also tried Meipass, didnt work either.

    Using PyInstaller hooks (--add-binary):

    pyinstaller --onefile --add-binary "path/to/ffmpeg.exe;." discordmusicbot.py

    Continue reading...

Compartilhe esta Página