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

Option to suppress console window when extracting audio #4

Open
aalramadan opened this issue Jul 10, 2024 · 0 comments
Open

Option to suppress console window when extracting audio #4

aalramadan opened this issue Jul 10, 2024 · 0 comments

Comments

@aalramadan
Copy link

I'm using the audio-extract module in my PySide6 application and compiling it into an executable using PyInstaller. However, I noticed that a console window kept popping up when the audio-extract function was called.

After some investigation, I found that the console window was appearing due to the subprocess.run() command in the extract_audio function within the audio-extract module. This command is used to run the ffmpeg command in a subprocess, and by default, it opens a console window.

To suppress the console window, I used the subprocess.STARTUPINFO class to control the visibility of the console window. Here's the modified extract_audio function:

import subprocess

def extract_audio(input_path: str, output_path: str = "./audio.mp3", output_format: str = "mp3",
                  start_time: str = "00:00:00",
                  duration: float = None,
                  overwrite: bool = False):
    # ... (rest of your code)

    # Create a STARTUPINFO object
    startupinfo = subprocess.STARTUPINFO()

    # Set the STARTF_USESHOWWINDOW flag
    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

    # Set wShowWindow to SW_HIDE to hide the console window
    startupinfo.wShowWindow = subprocess.SW_HIDE

    # Pass startupinfo to subprocess.run
    result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo)

    # ... (rest of your code)

This modification successfully suppressed the console window when the extract_audio function was called.

I wanted to bring this to your attention as other users might encounter the same issue. Perhaps there could be a way to incorporate this solution as an option into the audio-extract module.

And thank you for the great package!

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

No branches or pull requests

1 participant