wink-rtsp-stats

Metrics Guide

A comprehensive guide to understanding the metrics, diagnostics, and features provided by wink-rtsp-stats for RTSP/RTP stream analysis.

Version 1.1.0 | February 2026

WINK Streaming

Table of Contents

1. Overview

wink-rtsp-stats is a lightweight RTSP/RTP stream analyzer that collects real-time statistics without decoding video. It connects to RTSP cameras and IP video sources to measure network-level quality metrics that indicate stream health.

Key Use Cases

How It Works

The tool connects to RTSP sources using standard RTSP/RTP protocols. It analyzes RTP packet headers and timing without decoding video frames, resulting in minimal CPU usage and no codec dependencies.

No Video Decoding: All metrics are derived from RTP packet analysis at the protocol level. This means the tool works with any codec and requires minimal resources.

2. Stream Fingerprint

The stream fingerprint provides a one-line summary of the stream's technical characteristics, making it easy to identify and compare streams.

Format

H264 Main L4.1 | 1920x1080@29.97 | PT=96 | SSRC=0x8f32a1b4 | RTP/TCP

Components

Component Description Example
Codec Video/audio codec with profile and level H264 Main L4.1
Resolution Width x Height @ Framerate 1920x1080@29.97
PT RTP Payload Type number PT=96
SSRC Synchronization Source identifier SSRC=0x8f32a1b4
Transport RTP transport mode RTP/TCP or RTP/UDP

H.264 Profile Levels Explained

Profile Use Case
Baseline Low-complexity, mobile devices, video conferencing
Main Standard broadcasting, good compression
High HD broadcasting, Blu-ray, best compression
High 10 10-bit color depth, professional video

Level Specifications

Level Max Resolution Max Bitrate
L3.0 720p @ 30fps 10 Mbps
L3.1 720p @ 60fps 14 Mbps
L4.0 1080p @ 30fps 20 Mbps
L4.1 1080p @ 30fps 50 Mbps
L5.0 1080p @ 60fps 135 Mbps
L5.1 4K @ 30fps 240 Mbps

Why It Matters

The fingerprint helps you quickly identify:

3. Packet Loss Analysis

Packet loss is the most critical indicator of stream quality issues. Even small amounts of loss can cause visible artifacts and playback problems.

Metrics

Metric Description
packets_total Total RTP packets received
packets_lost_estimated Estimated lost packets (from sequence gaps)
packets_out_of_order Packets that arrived late (reordered)
packets_duplicated Duplicate packets received

How Loss is Detected

RTP packets contain a 16-bit sequence number that increments by 1 for each packet. When wink-rtsp-stats sees a gap (e.g., receives packet 100, then 103), it estimates that packets 101 and 102 were lost.

Loss Severity Guide

Loss % Status Impact Action
0-0.1% Excellent Imperceptible None needed
0.1-1% Good Minor artifacts possible Monitor
1-5% Warning Visible artifacts, freezing Investigate network
5-10% Poor Significant quality loss Immediate action needed
>10% Critical Stream unusable Check connectivity

Common Causes of Packet Loss

  1. Network congestion: Too much traffic on the network segment
  2. Bandwidth limitations: Stream bitrate exceeds available bandwidth
  3. WiFi interference: Especially for wireless cameras
  4. Buffer overflows: Switches/routers dropping packets
  5. MTU issues: Packet fragmentation problems
  6. Faulty hardware: Bad cables, failing switch ports

Remediation Steps

  1. Check network utilization on the path from camera to receiver
  2. Verify QoS settings prioritize video traffic
  3. Test with wired connection if using WiFi
  4. Check for duplex mismatches on switch ports
  5. Verify camera's bitrate doesn't exceed network capacity
  6. Consider using TCP transport if UDP shows loss

4. Jitter Measurement

Jitter measures the variation in packet arrival times, indicating network stability. High jitter can cause playback stuttering even without packet loss.

Metrics

Metric Description
jitter_ms_avg Average jitter (RFC 3550 calculation)
jitter_ms_max Maximum jitter observed

RFC 3550 Jitter Calculation

Jitter is calculated using the standard RFC 3550 formula:

J(i) = J(i-1) + (|D(i-1,i)| - J(i-1)) / 16

Where D is the difference between actual and expected inter-arrival times. This provides a smoothed running estimate that's comparable across implementations.

Jitter Severity Guide

Jitter Status Impact Action
<10ms Excellent No impact None needed
10-30ms Good Easily buffered Monitor
30-50ms Warning May cause issues Increase buffer
50-100ms Poor Visible stuttering Investigate
>100ms Critical Severe playback issues Immediate action

Common Causes of High Jitter

  1. Network congestion: Variable queuing delays
  2. Route changes: Packets taking different paths
  3. WiFi contention: Variable access times
  4. CPU load on camera: Inconsistent encoding
  5. Virtualization: VM scheduling delays

Remediation Steps

  1. Implement QoS to prioritize video traffic
  2. Use traffic shaping to smooth out bursts
  3. Add jitter buffers on the receiving end
  4. Check for competing high-bandwidth traffic
  5. Consider dedicated VLANs for video

5. Bitrate Monitoring

Bitrate indicates the data rate of the video stream, essential for capacity planning and quality assessment.

Metrics

Metric Description
bitrate_kbps_avg Average bitrate since start (kbps)
bitrate_kbps_instant Current bitrate (rolling window)
total_bitrate_kbps_avg Combined bitrate of all streams

Understanding Bitrate Fluctuations

Video bitrate naturally fluctuates based on:

Bitrate Trend Indicators

The live display shows bitrate trends:

Capacity Planning

When planning network capacity, account for:

Tip: For VBR streams, plan for at least 2x the average bitrate to handle peak moments during high motion or scene changes.

6. Expected vs Observed Bitrate

This feature compares the actual measured bitrate against the expected bitrate declared in the SDP (Session Description Protocol).

How It Works

Cameras often advertise their expected bitrate in the SDP using the b= line:

wink-rtsp-stats parses this value and compares it to the measured bitrate.

Deviation Status

Status Deviation Meaning
OK ±30% Bitrate within expected range
HIGH >+30% Bitrate significantly exceeds SDP declaration
LOW <-30% Bitrate significantly below SDP declaration

What Deviations Mean

HIGH Deviation (>+30%)

LOW Deviation (<-30%)

When No SDP b= Line Exists

Many cameras don't include bandwidth information in their SDP. In this case, the display shows "(no SDP b= line)" and no deviation is calculated.

7. RTP Clock Drift

Clock drift measures the divergence between the camera's RTP timestamp clock and real wall-clock time. This is critical for recording and multi-camera synchronization.

Understanding RTP Timestamps

RTP packets contain a 32-bit timestamp that increments based on the media clock rate (typically 90,000 Hz for video). In a perfect system:

How Drift is Measured

wink-rtsp-stats tracks:

  1. The RTP timestamp and wall time of the first packet
  2. The RTP timestamp and wall time of subsequent packets
  3. Compares expected vs actual RTP timestamp progression

Drift Status

Status Drift Rate Meaning
OK <50ms/min Clock is stable
DRIFTING 50-200ms/min Clock is slowly diverging
UNSTABLE >200ms/min Significant clock issues

Drift Direction

What Causes Clock Drift

  1. Cheap oscillators: Low-quality crystal oscillators in budget cameras
  2. Temperature variations: Crystal frequency changes with temperature
  3. CPU load: Software timestamps affected by system load
  4. Clock domains: Mismatched clocks between components
  5. Encoder issues: Timestamp generation bugs

Impact of Clock Drift

Use Case Impact
Recording Files may have A/V sync issues
Multi-camera Cameras become progressively out of sync
Live streaming Player buffers may overflow/underflow
Synchronization NTP-based correlation becomes inaccurate

Remediation Steps

  1. Firmware update: Check for camera firmware updates
  2. NTP sync: Enable NTP on the camera if available
  3. Player compensation: Use adaptive sync in your player
  4. Hardware upgrade: Consider higher-quality cameras
  5. Periodic reconnection: Reconnect streams periodically to reset drift

8. Packet Burstiness

Burstiness measures how evenly packets are distributed over time. Bursty traffic can cause network issues even when average bandwidth is sufficient.

Metrics

Metric Description
burst_avg_per_100ms Average packets per 100ms window
burst_max_per_100ms Maximum packets in any 100ms window
burst_ratio max / avg (higher = more bursty)
burst_status SMOOTH / MODERATE / BURSTY

Status Thresholds

Status Burst Ratio Meaning
SMOOTH <1.5 Evenly distributed packets
MODERATE 1.5-3.0 Some clustering, typical for video
BURSTY >3.0 Significant packet clustering

Why Burstiness Matters

Bursty traffic can cause:

Causes of High Burstiness

  1. I-frame delivery: Keyframes sent as rapid packet bursts
  2. Scene cuts: Sudden complexity changes
  3. Encoder buffering: Encoder holds packets then releases in batch
  4. Network buffering: Intermediate devices batching packets
  5. TCP congestion control: TCP sends in bursts after ACKs

Remediation Steps

  1. Traffic shaping: Smooth out bursts at the source or edge
  2. Larger buffers: Increase receive buffer sizes
  3. QoS: Ensure video traffic has priority queuing
  4. Lower GOP size: More frequent I-frames = smaller bursts
  5. CBR encoding: Constant bitrate reduces peak bursts

9. SSRC Stability

SSRC (Synchronization Source) stability monitors whether the stream's identity changes during a session, which can indicate camera reboots or encoder resets.

What is SSRC?

Each RTP stream has a 32-bit SSRC identifier that uniquely identifies the source. This should remain constant throughout a session.

How Stability is Measured

  1. Stabilization window: First 5 seconds after connection
  2. Initial SSRCs: SSRCs seen during stabilization are recorded
  3. Post-stabilization: Any new SSRCs trigger a warning

Warning Indicators

When SSRC changes after stabilization:

WARNING: SSRC changed (1 new sources after stabilization - possible camera reboot / encoder reset)

What SSRC Changes Mean

Cause Explanation
Camera reboot Camera restarted, generating new SSRC
Encoder reset Internal encoder restarted
Stream switch Camera switched between streams
Network issue Severe packet loss caused resync
Firmware bug Camera incorrectly regenerates SSRC

Why Stability Matters

Remediation Steps

  1. Check camera logs for reboot events
  2. Verify power supply stability
  3. Update camera firmware
  4. Check for overheating issues
  5. Monitor network for severe loss events

10. Transport Path Information

Shows how RTP packets are being transported from the camera to wink-rtsp-stats, helping diagnose connectivity and firewall issues.

Transport Modes

Mode Description Pros Cons
RTSP over TCP (interleaved) RTP packets tunneled within RTSP TCP connection Firewall-friendly, reliable Higher latency, more overhead
RTP over UDP RTP sent directly via UDP Lower latency, less overhead May have loss, firewall issues

RTCP Information

RTCP (RTP Control Protocol) provides feedback and statistics:

Why RTCP Matters

RTCP provides:

Choosing Transport Mode

Use TCP when:
Use UDP when:

11. Timestamp Continuity

Monitors RTP timestamp progression for discontinuities that may indicate stream interruptions or encoder issues.

Metrics

Metric Description
timestamp_jumps Large forward timestamp discontinuities
timestamp_resets Backward timestamp jumps

Display Format

In Timing Analysis:

What Discontinuities Mean

Timestamp Jumps (forward)

Timestamp Resets (backward)

12. Exit Codes

wink-rtsp-stats returns specific exit codes for CI/CD integration and scripting, enabling automated quality gates.

Exit Code Reference

Code Name Meaning
0 Success Completed without threshold violations
1 General Error Unexpected error
2 Loss Threshold Packet loss exceeded --loss-threshold
3 Jitter Threshold Jitter exceeded --jitter-threshold
4 RTP Stalled No RTP packets received
5 RTSP Failed Could not connect to RTSP server

Using Thresholds

# Exit with code 2 if loss > 1%
wink-rtsp-stats monitor rtsp://camera/stream --duration 60s --loss-threshold 1.0

# Exit with code 3 if jitter > 30ms
wink-rtsp-stats monitor rtsp://camera/stream --duration 60s --jitter-threshold 30

# Combined thresholds
wink-rtsp-stats monitor rtsp://camera/stream \
  --duration 60s \
  --loss-threshold 1.0 \
  --jitter-threshold 30

CI/CD Integration Example

#!/bin/bash
# Camera health check script

CAMERA_URL="rtsp://camera/stream"
DURATION="30s"
LOSS_THRESHOLD="2.0"
JITTER_THRESHOLD="50"

wink-rtsp-stats monitor "$CAMERA_URL" \
  --duration "$DURATION" \
  --loss-threshold "$LOSS_THRESHOLD" \
  --jitter-threshold "$JITTER_THRESHOLD" \
  --output json > /tmp/camera-stats.json

EXIT_CODE=$?

case $EXIT_CODE in
  0) echo "Camera healthy" ;;
  2) echo "ALERT: Packet loss exceeded threshold"; exit 1 ;;
  3) echo "ALERT: Jitter exceeded threshold"; exit 1 ;;
  4) echo "ALERT: No RTP packets received"; exit 1 ;;
  5) echo "ALERT: Cannot connect to camera"; exit 1 ;;
  *) echo "ALERT: Unknown error"; exit 1 ;;
esac

13. JSON Schema

Version 1.1 introduces a schema version field and units metadata for programmatic consumption.

Schema Version

{
  "tool": "wink-rtsp-stats",
  "version": "1.1.0",
  "schema_version": "1.1",
  ...
}

The schema_version field allows consumers to handle format changes gracefully.

Units Metadata

{
  "_units": {
    "duration_s": "seconds",
    "bitrate_kbps": "kilobits per second",
    "jitter_ms": "milliseconds",
    "clock_rate": "Hz",
    "rtsp_connect_time_ms": "milliseconds",
    "first_rtp_time_ms": "milliseconds",
    "interarrival_ms": "milliseconds",
    "clock_drift_ms": "milliseconds per minute",
    "burst_per_100ms": "packets per 100ms window"
  }
}

New v1.1 Stream Fields

{
  "streams": [{
    "burst_avg_per_100ms": 35.0,
    "burst_max_per_100ms": 69,
    "burst_ratio": 1.97,
    "burst_status": "MODERATE",
    "clock_drift_ms": -150.2,
    "clock_drift_trend_ms_per_min": -45.3,
    "clock_drift_status": "DRIFTING",
    "expected_bitrate_kbps": 5000,
    "bitrate_deviation_pct": -15.5,
    "bitrate_deviation": "OK",
    "fingerprint": "H264 Main L4.1 | 1920x1080@29.97 | PT=96 | SSRC=0x8f32a1 | RTP/TCP"
  }]
}

New v1.1 Summary Fields

{
  "summary": {
    "ssrc_stable": true,
    "ssrc_change_count": 0,
    "ssrcs_initial": ["0x8f32a1b4"],
    "ssrcs_new": [],
    "transport_mode": "RTSP over TCP (interleaved)",
    "rtcp_received": false,
    "rtcp_count": 0
  }
}

14. Troubleshooting Guide

High Packet Loss

Symptoms:

Diagnostic Steps:

  1. Check transport_mode - try TCP if using UDP
  2. Run ping to camera - check for ICMP loss
  3. Check switch port statistics for errors
  4. Verify network bandwidth is sufficient
  5. Check for WiFi interference if wireless

Solutions:

High Jitter

Symptoms:

Diagnostic Steps:

  1. Check burstiness - high burst ratio can cause jitter
  2. Look for network congestion
  3. Check camera CPU usage
  4. Verify no route flapping

Solutions:

Clock Drift Issues

Symptoms:

Diagnostic Steps:

  1. Check camera firmware version
  2. Verify NTP configuration on camera
  3. Check camera temperature
  4. Monitor over extended period

Solutions:

SSRC Instability

Symptoms:

Diagnostic Steps:

  1. Check camera logs for reboots
  2. Verify power supply stability
  3. Check for firmware bugs
  4. Monitor network for severe issues

Solutions:

Connection Failures

Symptoms:

Diagnostic Steps:

  1. Verify URL is correct
  2. Check credentials
  3. Test network connectivity
  4. Verify RTSP port is open

Solutions:

15. Command Reference

Basic Usage

# Monitor single camera
wink-rtsp-stats monitor rtsp://user:pass@camera:554/stream

# Monitor with duration
wink-rtsp-stats monitor rtsp://camera/stream --duration 60s

# JSON output
wink-rtsp-stats monitor rtsp://camera/stream --output json

# Force TCP transport
wink-rtsp-stats monitor rtsp://camera/stream --transport tcp

Quality Gates

# Fail if loss > 2%
wink-rtsp-stats monitor rtsp://camera/stream --loss-threshold 2.0

# Fail if jitter > 50ms
wink-rtsp-stats monitor rtsp://camera/stream --jitter-threshold 50

# Combined check for 5 minutes
wink-rtsp-stats monitor rtsp://camera/stream \
  --duration 5m \
  --loss-threshold 1.0 \
  --jitter-threshold 30

Multiple Cameras

# From file
wink-rtsp-stats monitor --file cameras.txt --duration 30s

# Limit concurrent
wink-rtsp-stats monitor --file cameras.txt --max-streams 10

Raw RTP Listening

# Listen on UDP port without RTSP
wink-rtsp-stats rtp --port 15002 --duration 30s

All Command Line Flags

Flag Default Description
--duration Run duration (e.g., 30s, 5m)
--interval 333ms Stats refresh interval
--output console Output format: console or json
--transport auto Force tcp or udp
--timeout 5s RTSP connection timeout
--rtp-timeout 10s Stall detection timeout
--loss-threshold 0 Exit code 2 if loss % exceeds
--jitter-threshold 0 Exit code 3 if jitter ms exceeds
--file - Load URLs from file
--max-streams 0 Limit concurrent streams
--no-ansi false Disable colors

16. Glossary

Term Definition
CBR Constant Bit Rate - encoder maintains fixed bitrate
GOP Group of Pictures - sequence of frames between I-frames
I-frame Intra-frame, complete picture, larger size
Jitter Variation in packet arrival times
P-frame Predicted frame, depends on previous frame
PT Payload Type - identifies codec in RTP header
QoS Quality of Service - traffic prioritization
RTCP RTP Control Protocol - provides feedback
RTP Real-time Transport Protocol - carries media
RTSP Real Time Streaming Protocol - controls streams
SDP Session Description Protocol - describes media
SSRC Synchronization Source - stream identifier
VBR Variable Bit Rate - bitrate changes with content

WINK RTSP Stats v1.1.0 Metrics Guide

Created by WINK Streaming - https://www.wink.co

February 2026