Add missing multi_res_output.py and update gpu_output.py
Some checks are pending
GPU Worker CI/CD / test (push) Waiting to run
GPU Worker CI/CD / deploy (push) Blocked by required conditions

- multi_res_output.py was not tracked, causing import errors
- Update gpu_output.py with recent changes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-04 20:26:10 +00:00
parent e2761798a8
commit 76e4a002a0
2 changed files with 484 additions and 1 deletions

View File

@@ -325,6 +325,20 @@ class GPUHLSOutput:
stderr=subprocess.PIPE, # Capture stderr for debugging
)
# Start thread to drain stderr (prevents pipe buffer from filling and blocking FFmpeg)
self._stderr_thread = threading.Thread(target=self._drain_stderr, daemon=True)
self._stderr_thread.start()
def _drain_stderr(self):
"""Drain FFmpeg stderr to prevent blocking."""
try:
for line in self._muxer.stderr:
line_str = line.decode('utf-8', errors='replace').strip()
if line_str:
print(f"[FFmpeg] {line_str}", file=sys.stderr)
except Exception as e:
print(f"[FFmpeg stderr] Error reading: {e}", file=sys.stderr)
def write(self, frame: Union[np.ndarray, 'cp.ndarray'], t: float = 0):
"""Write a frame using GPU encoding."""
if not self._is_open:
@@ -342,7 +356,15 @@ class GPUHLSOutput:
if encoded:
try:
self._muxer.stdin.write(encoded)
except BrokenPipeError:
except BrokenPipeError as e:
print(f"[GPUHLSOutput] FFmpeg pipe broken after {self._frames_in_segment} frames in segment, total segments: {self._current_segment}", file=sys.stderr)
# Check if muxer is still running
if self._muxer.poll() is not None:
print(f"[GPUHLSOutput] FFmpeg exited with code {self._muxer.returncode}", file=sys.stderr)
self._is_open = False
return
except Exception as e:
print(f"[GPUHLSOutput] Error writing to FFmpeg: {e}", file=sys.stderr)
self._is_open = False
return