imageio / imageio-ffmpeg

FFMPEG wrapper for Python
BSD 2-Clause "Simplified" License
221 stars 50 forks source link

When building a pyinstaller package on Windows with --windowed option, the packaged app fails to start #40

Open andryghb opened 4 years ago

andryghb commented 4 years ago

After investigating the reasons for such behaviour (without --windowed everything works fine), I narrowed it down to this part of code in _io.py

p = subprocess.Popen(
    cmd,
    stdin=subprocess.PIPE,
    stdout=subprocess.PIPE,
    stderr=None,
    **_popen_kwargs(prevent_sigint=True)
)

The comment that follows explains that stderr was deliberately set to None because if redirected to pipe on Windows, it causes ffmpeg to hang. On the other hand, stderr=None causes a problem with --windowed option on Windows (OSError: [WinError 6] The handle is invalid). My understanding is that Windows is trying to recreate stderr handle as it is set to None, but unable to do this due to --windowed mode.

A possible solution is to redirect stderr (and probably stdout too) to subprocess.DEVNULL instead of None, i.e.

stderr=subprocess.DEVNULL
almarklein commented 4 years ago

Thanks for this report!

A possible solution is to redirect stderr (and probably stdout too) to subprocess.DEVNULL instead of None,

Interesting. have you tried whether this works for you?