mirror of
https://github.com/kerberos-io/agent.git
synced 2026-08-23 15:08:32 +00:00
Adjust MinNormalGOPMs threshold to prevent false positives on loop seams
This commit is contained in:
@@ -32,14 +32,23 @@ const MacEpochOffset uint64 = 2082844800
|
|||||||
// resulting in ~3 second fragments (assuming a typical GOP interval).
|
// resulting in ~3 second fragments (assuming a typical GOP interval).
|
||||||
const FragmentDurationMs = 3000
|
const FragmentDurationMs = 3000
|
||||||
|
|
||||||
// MinNormalGOPMs is the minimum spacing we expect between two consecutive
|
// MinNormalGOPMs is the maximum spacing between two consecutive IDRs that
|
||||||
// IDRs of a healthy source (typical encoders produce IDRs every 1000ms or
|
// we still consider an anomalous "loop/restart seam". When two keyframes
|
||||||
// more). When two keyframes arrive closer than this, we treat the second one
|
// arrive closer than this, we treat the second one as an upstream
|
||||||
// as an upstream restart/loop-seam and force a fresh fragment so the seam
|
// restart/loop-seam and force a fresh fragment so the seam IDR cannot end
|
||||||
// IDR cannot end up as a mid-fragment sync sample. The check only runs when
|
// up as a mid-fragment sync sample. The check only runs when the current
|
||||||
// the current fragment has not yet reached FragmentDurationMs, so it never
|
// fragment has not yet reached FragmentDurationMs.
|
||||||
// fires during normal multi-GOP fragments at intended GOP boundaries.
|
//
|
||||||
const MinNormalGOPMs = 950
|
// This must be set well below the smallest plausible *legitimate* GOP
|
||||||
|
// length. Typical IP cameras use GOP intervals of 1000-2000 ms, and the
|
||||||
|
// arrival timing of consecutive IDRs can jitter by a few hundred ms due to
|
||||||
|
// network/RTSP buffering. A threshold close to 1 s (e.g. 950) caused
|
||||||
|
// false positives on cameras with ~1 s GOPs (warnings like
|
||||||
|
// "gap=800 ms / 300 ms / 200 ms" while the stream itself was healthy).
|
||||||
|
// 400 ms is comfortably below any realistic GOP yet still catches the
|
||||||
|
// virtual-rtsp / ffmpeg loop-seam pattern (seam IDRs typically arrive
|
||||||
|
// 100-200 ms after the prior IDR).
|
||||||
|
const MinNormalGOPMs = 400
|
||||||
|
|
||||||
type MP4 struct {
|
type MP4 struct {
|
||||||
// FileName is the name of the file
|
// FileName is the name of the file
|
||||||
|
|||||||
@@ -51,8 +51,11 @@ func TestMP4LoopSeamIsolation(t *testing.T) {
|
|||||||
|
|
||||||
// 17 seconds of normal content (last "good" IDR at sec 17).
|
// 17 seconds of normal content (last "good" IDR at sec 17).
|
||||||
emit(17*30, 30)
|
emit(17*30, 30)
|
||||||
// Seam: IDR arrives ~867ms after previous (vs normal 1000ms).
|
// Seam: IDR arrives ~150ms after previous (vs normal ~1000ms).
|
||||||
pts -= 100
|
// This matches the realistic virtual-rtsp / ffmpeg `-stream_loop`
|
||||||
|
// loop boundary, where the new clip's first IDR is emitted shortly
|
||||||
|
// after the previous clip's final IDR.
|
||||||
|
pts -= 820
|
||||||
emit(13*30, 30)
|
emit(13*30, 30)
|
||||||
|
|
||||||
mp4Video.Close(&models.Config{Signing: &models.Signing{PrivateKey: ""}})
|
mp4Video.Close(&models.Config{Signing: &models.Signing{PrivateKey: ""}})
|
||||||
|
|||||||
Reference in New Issue
Block a user