| 67 | } |
| 68 | |
| 69 | start(): void { |
| 70 | this.stopped = false; |
| 71 | this.spawnProc(); |
| 72 | if (!this.watchdog) { |
| 73 | this.watchdog = setInterval(() => { |
| 74 | if (this.stopped || !this.proc) return; |
| 75 | if (this.lastDataAt && Date.now() - this.lastDataAt > STALL_MS) { |
| 76 | console.error("[mse] stream stalled — restarting ffmpeg"); |
| 77 | this.lastError = "stream stalled; reconnecting"; |
| 78 | this.lastDataAt = 0; |
| 79 | this.kill(); |
| 80 | this.restartTimer = setTimeout(() => this.spawnProc(), 1000); |
| 81 | } |
| 82 | }, 2000); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | stop(): void { |
| 87 | this.stopped = true; |