Verify RTSP probes from frame progress

This commit is contained in:
seo-amugae committed 2026-10-08 03:08:13 +09:00
1 parent 4cfce2ea2d
commit 9513ca6e15
1 file changed
+25 -6
+25 -6
View File
@@ -3006,9 +3006,10 @@ function New-RtspHealthProbeArguments {
param([int]$Channel) param([int]$Channel)
return @( return @(
"-hide_banner", "-loglevel", "error", "-nostdin", "-hide_banner", "-loglevel", "error", "-nostdin", "-nostats",
"-progress", "pipe:1",
"-rtsp_transport", "tcp", "-rtsp_transport", "tcp",
"-rw_timeout", [string]($RtspHealthTimeoutSec * 1000000), "-timeout", [string]($RtspHealthTimeoutSec * 1000000),
"-i", "$RTSPPublishBase/monitor$Channel", "-i", "$RTSPPublishBase/monitor$Channel",
"-map", "0:v:0", "-frames:v", "1", "-map", "0:v:0", "-frames:v", "1",
"-an", "-sn", "-dn", "-f", "null", "NUL" "-an", "-sn", "-dn", "-f", "null", "NUL"
@@ -3022,17 +3023,21 @@ function Test-RtspStreamFrames {
try { try {
for ($channel = 1; $channel -le $ChannelCount; $channel++) { for ($channel = 1; $channel -le $ChannelCount; $channel++) {
$errorLog = Join-Path $LogDir "rtsp-health-monitor$channel.log" $errorLog = Join-Path $LogDir "rtsp-health-monitor$channel.log"
Remove-Item -LiteralPath $errorLog -Force -ErrorAction SilentlyContinue $progressLog = Join-Path $LogDir "rtsp-health-monitor$channel.progress"
Remove-Item -LiteralPath $errorLog,$progressLog `
-Force -ErrorAction SilentlyContinue
$process = Start-Process -FilePath $FFmpegPath ` $process = Start-Process -FilePath $FFmpegPath `
-ArgumentList (Join-ProcessArguments (New-RtspHealthProbeArguments $channel)) ` -ArgumentList (Join-ProcessArguments (New-RtspHealthProbeArguments $channel)) `
-WorkingDirectory $BaseDir -WindowStyle Hidden ` -WorkingDirectory $BaseDir -WindowStyle Hidden `
-RedirectStandardOutput $progressLog `
-RedirectStandardError $errorLog -PassThru -RedirectStandardError $errorLog -PassThru
$probes += [PSCustomObject]@{ $probes += [PSCustomObject]@{
Channel = $channel Channel = $channel
Process = $process Process = $process
ErrorLog = $errorLog ErrorLog = $errorLog
ProgressLog = $progressLog
} }
} }
@@ -3055,8 +3060,20 @@ function Test-RtspStreamFrames {
} }
$probe.Process.WaitForExit() $probe.Process.WaitForExit()
if ($probe.Process.ExitCode -ne 0) { $progress = @()
$detail = "exit=$($probe.Process.ExitCode)" if (Test-Path -LiteralPath $probe.ProgressLog) {
$progress = @(
Get-Content -LiteralPath $probe.ProgressLog `
-ErrorAction SilentlyContinue
)
}
$hasFrame = @($progress | Where-Object {
$_ -match '^frame=([1-9][0-9]*)$'
}).Count -gt 0
$reachedEnd = $progress -contains "progress=end"
if (-not ($hasFrame -and $reachedEnd)) {
$detail = "FFmpeg progress에 디코딩 완료 프레임 없음"
if (Test-Path -LiteralPath $probe.ErrorLog) { if (Test-Path -LiteralPath $probe.ErrorLog) {
$tail = @( $tail = @(
Get-Content -LiteralPath $probe.ErrorLog -Tail 3 ` Get-Content -LiteralPath $probe.ErrorLog -Tail 3 `
@@ -3611,7 +3628,9 @@ function Invoke-SimulationTests {
Invoke-SimulationCase "RTSP 상태 검사는 새 수신기로 실제 영상 1프레임 요구" { Invoke-SimulationCase "RTSP 상태 검사는 새 수신기로 실제 영상 1프레임 요구" {
$arguments = @(New-RtspHealthProbeArguments 2) $arguments = @(New-RtspHealthProbeArguments 2)
return ($arguments -contains '-rw_timeout' -and return ($arguments -contains '-timeout' -and
$arguments -contains '-progress' -and
$arguments -contains 'pipe:1' -and
$arguments -contains '-frames:v' -and $arguments -contains '-frames:v' -and
$arguments -contains '1' -and $arguments -contains '1' -and
$arguments -contains '0:v:0' -and $arguments -contains '0:v:0' -and