Open 1893945 opened 2 years ago
add code : startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags = subprocess.CREATE_NEW_CONSOLE|subprocess.STARTF_USESHOWWINDOW startupinfo.wShowWindow = subprocess.SW_HIDE
p = subprocess.Popen(conversion_command, stdin=devnull, stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo)
AudioSegment.export not pop up cmd window, But AudioSegment.from_mp3 pop up cmd window yet.
why?
Problem solved.
startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags = subprocess.CREATE_NEW_CONSOLE|subprocess.STARTF_USESHOWWINDOW startupinfo.wShowWindow = subprocess.SW_HIDE
the codes is available. AudioSegment.from_mp3 called pydub‘s utils.py, some subprocess.Pooen in utils.py, set them all “startupinfo=startupinfo”.
Where do I add this code to? Is it in "audio_segment.py"? Thank you!
Thanks a lot for your solution!
I found another way to modify subprocess.Popen
in pydub without changing its internal files.
patch_subprocess.py
with the following content:
import subprocess
class NoWindowPopen(subprocess.Popen): def init(self, *args, **kwargs): startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags = subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW startupinfo.wShowWindow = subprocess.SW_HIDE
kwargs["startupinfo"] = startupinfo
super().__init__(*args, **kwargs)
subprocess.Popen = NoWindowPopen
2. Import `patch_subprocess` before import `pydub`
import patch_subprocess from pydub import AudioSegment
Steps to reproduce
Expected behavior
I used pyinstaller cteate a quiet exe, when Running AudioSegment.from_mp3 or audio.export not need to pop up the cmd command window.
Actual behavior
But when Running AudioSegment.from_mp3 or AudioSegment.export ,the cmd command window always flash
Your System configuration
Is there an audio file you can include to help us reproduce?
You can include the audio file in this issue - just put it in a zip file and drag/drop the zip file into the github issue.