fix: wait for mediamtx port 8554 before starting ffmpeg

This commit is contained in:
tian 2026-07-20 14:27:07 +08:00
parent 0207593975
commit 4ad664ecc5

View File

@ -73,6 +73,15 @@ function Invoke-Start {
# 1. RTSP server
Write-Banner "1/5 RTSP Server (mediamtx)"
Start-Detached "mediamtx" $mediamtx
Write-Host " [WAIT] 等待 RTSP 服务就绪..." -ForegroundColor DarkGray
$ready = $false
for ($i = 0; $i -lt 10; $i++) {
Start-Sleep 1
$tcp = netstat -an 2>$null | Select-String ':8554.*LISTENING'
if ($tcp) { $ready = $true; break }
}
if ($ready) { Write-Host " [OK] RTSP 服务就绪" -ForegroundColor Green }
else { Write-Host " [WARN] RTSP 服务可能未就绪" -ForegroundColor Yellow }
# 2. ffmpeg push
Write-Banner "2/5 RTSP 推流 (ffmpeg)"