more stuff

This commit is contained in:
2025-07-27 08:19:42 -07:00
parent 7431954482
commit 9faaf4ed57
5 changed files with 21 additions and 21 deletions

View File

@@ -132,13 +132,22 @@ class StreamingFrameWriter:
bufsize=10**8 # Large buffer for performance
)
# Test if ffmpeg starts successfully (quick check)
import time
time.sleep(0.1) # Give ffmpeg time to fail if it's going to
if self.ffmpeg_process.poll() is not None:
# Process already died - read error
stderr = self.ffmpeg_process.stderr.read().decode()
raise RuntimeError(f"FFmpeg failed immediately: {stderr}")
# Set process to ignore SIGINT (Ctrl+C) - we'll handle it
if hasattr(signal, 'pthread_sigmask'):
signal.pthread_sigmask(signal.SIG_BLOCK, [signal.SIGINT])
except Exception as e:
# Try CPU fallback if GPU encoding fails
if 'nvenc' in self.ffmpeg_cmd:
if 'nvenc' in ' '.join(self.ffmpeg_cmd):
print(f"⚠️ GPU encoding failed, trying CPU fallback...")
self.ffmpeg_cmd = self._build_ffmpeg_command('libx264', 'medium', 18)
self._start_ffmpeg()