kkroening / ffmpeg-python

Python bindings for FFmpeg - with complex filtering support
Apache License 2.0
9.97k stars 885 forks source link

Running without console window? #686

Open amamic1803 opened 2 years ago

amamic1803 commented 2 years ago

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?).

amamic1803 commented 2 years ago

Solved. (https://stackoverflow.com/a/71741286/9927277) @kkroening could you review linked answer? I don't understand what he did and why it works, but if it is a good fix it would be nice to include it in official pip release.