-
Notifications
You must be signed in to change notification settings - Fork 899
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
Running without console window? #686
Comments
Solved. (https://stackoverflow.com/a/71741286/9927277) |
The most elegant method is using monkey patch, note that the version of ffmpeg-python is 0.2.0: import subprocess
import sys
import ffmpeg
from ffmpeg._run import output_operator
# monkey patch
@output_operator()
def patched_run_async(
stream_spec,
cmd='ffmpeg',
pipe_stdin=False,
pipe_stdout=False,
pipe_stderr=False,
quiet=False,
overwrite_output=False,
):
# hide windows console
creationflags = 0
if sys.platform == "win32":
creationflags = subprocess.CREATE_NO_WINDOW
args = ffmpeg._run.compile(stream_spec, cmd, overwrite_output=overwrite_output)
stdin_stream = subprocess.PIPE if pipe_stdin else None
stdout_stream = subprocess.PIPE if pipe_stdout or quiet else None
stderr_stream = subprocess.PIPE if pipe_stderr or quiet else None
return subprocess.Popen(
args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream, creationflags=creationflags
)
ffmpeg._run.run_async = patched_run_async |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm making a python script to convert video or image to ASCII art and I need ffmpeg for the last part. The thing is that when I build EXE file using PyInstaller (and select -noconsole option), when code execution comes to the point when ffmpeg is needed, console window still opens for each ffmpeg process opened. I open two processes, code for which is provided here:
process_in = ffmpeg.input(open_path, r=fps)[v_stream_indx].output('pipe:', format='rawvideo', pix_fmt='rgb24', r=fps).run_async(pipe_stdout=True, cmd=ffmpeg_path)
process_out = ffmpeg.input('pipe:', format='rawvideo', pix_fmt='rgb24', s=f'{width}x{height}', r=fps).output(ffmpeg.input(open_path, r=fps, vn=None), save_path, pix_fmt=pixel_format, r=fps, vcodec=og_codec, codec="copy").overwrite_output().run_async(pipe_stdin=True, cmd=ffmpeg_path)
Of course I don't want those console windows as my app has GUI. Strangely, there is no output in any of those 2 windows (I would expect it to be because there are many logs printed out when run from pycharm where main script output is printed out, BTW is there a way to disable that?).
The text was updated successfully, but these errors were encountered: