Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Image worker falls back to standard input when the private handle cannot be set up

Bowen Xue64849475f31f
diff --git a/freevideo_engine/image_gen/worker.py b/freevideo_engine/image_gen/worker.py
index ec5d8ce..3fffbd7 100644
--- a/freevideo_engine/image_gen/worker.py
+++ b/freevideo_engine/image_gen/worker.py
@@ -154,7 +154,10 @@ def main():
stream = None
if os.name == 'nt':
from ..win32 import private_stdin
- stream = private_stdin()
+ try:
+ stream = private_stdin()
+ except OSError as error:
+ print('private stdin unavailable, reading stdin directly: %s' % error, file=sys.stderr, flush=True)
serve(args.pack_dir, device=args.device, idle_seconds=args.idle_seconds, stream=stream)
return 0
diff --git a/freevideo_engine/win32.py b/freevideo_engine/win32.py
index d01ddb3..e89c740 100644
--- a/freevideo_engine/win32.py
+++ b/freevideo_engine/win32.py
@@ -65,12 +65,18 @@ def private_stdin(encoding='utf-8'):
import msvcrt
import sys
private = os.dup(sys.stdin.fileno())
- null = os.open(os.devnull, os.O_RDONLY)
try:
- os.dup2(null, 0)
- finally:
- os.close(null)
- checked(kernel32().SetStdHandle(DWORD(-10 & 0xffffffff), msvcrt.get_osfhandle(0))) # STD_INPUT_HANDLE
+ null = os.open(os.devnull, os.O_RDONLY)
+ try:
+ os.dup2(null, 0)
+ finally:
+ os.close(null)
+ checked(kernel32().SetStdHandle(DWORD(-10 & 0xffffffff), msvcrt.get_osfhandle(0))) # STD_INPUT_HANDLE
+ except OSError:
+ # Put the pipe back so the caller can still read from sys.stdin.
+ os.dup2(private, 0)
+ os.close(private)
+ raise
return open(private, encoding=encoding, errors=sys.stdin.errors)