more stuff
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -34,6 +34,11 @@ class SAM2StreamingProcessor:
|
||||
self.config = config
|
||||
self.device = torch.device(config.get('hardware', {}).get('device', 'cuda'))
|
||||
|
||||
# Processing parameters (set before _init_predictor)
|
||||
self.memory_offload = config.get('matting', {}).get('memory_offload', True)
|
||||
self.fp16 = config.get('matting', {}).get('fp16', True)
|
||||
self.correction_interval = config.get('matting', {}).get('correction_interval', 300)
|
||||
|
||||
# SAM2 model configuration
|
||||
model_cfg = config.get('matting', {}).get('sam2_model_cfg', 'sam2.1_hiera_l')
|
||||
checkpoint = config.get('matting', {}).get('sam2_checkpoint',
|
||||
@@ -43,11 +48,6 @@ class SAM2StreamingProcessor:
|
||||
self.predictor = None
|
||||
self._init_predictor(model_cfg, checkpoint)
|
||||
|
||||
# Processing parameters
|
||||
self.memory_offload = config.get('matting', {}).get('memory_offload', True)
|
||||
self.fp16 = config.get('matting', {}).get('fp16', True)
|
||||
self.correction_interval = config.get('matting', {}).get('correction_interval', 300)
|
||||
|
||||
# State management
|
||||
self.states = {} # eye -> inference state
|
||||
self.object_ids = []
|
||||
|
||||
Reference in New Issue
Block a user