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
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.
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.
The stream fingerprint provides a one-line summary of the stream's technical characteristics, making it easy to identify and compare streams.
| 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 |
| 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 | 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 |
The fingerprint helps you quickly identify:
Packet loss is the most critical indicator of stream quality issues. Even small amounts of loss can cause visible artifacts and playback problems.
| 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 |
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 % | 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 |
Jitter measures the variation in packet arrival times, indicating network stability. High jitter can cause playback stuttering even without packet loss.
| Metric | Description |
|---|---|
jitter_ms_avg |
Average jitter (RFC 3550 calculation) |
jitter_ms_max |
Maximum jitter observed |
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 | 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 |
Bitrate indicates the data rate of the video stream, essential for capacity planning and quality assessment.
| 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 |
Video bitrate naturally fluctuates based on:
The live display shows bitrate trends:
When planning network capacity, account for:
This feature compares the actual measured bitrate against the expected bitrate declared in the SDP (Session Description Protocol).
Cameras often advertise their expected bitrate in the SDP using the b= line:
b=AS:5000 - Application-Specific bandwidth in kbpsb=TIAS:5000000 - Transport Independent bandwidth in bpswink-rtsp-stats parses this value and compares it to the measured bitrate.
| Status | Deviation | Meaning |
|---|---|---|
| OK | ±30% | Bitrate within expected range |
| HIGH | >+30% | Bitrate significantly exceeds SDP declaration |
| LOW | <-30% | Bitrate significantly below SDP declaration |
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.
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.
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:
wink-rtsp-stats tracks:
| Status | Drift Rate | Meaning |
|---|---|---|
| OK | <50ms/min | Clock is stable |
| DRIFTING | 50-200ms/min | Clock is slowly diverging |
| UNSTABLE | >200ms/min | Significant clock issues |
| 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 |
Burstiness measures how evenly packets are distributed over time. Bursty traffic can cause network issues even when average bandwidth is sufficient.
| 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 | 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 |
Bursty traffic can cause:
SSRC (Synchronization Source) stability monitors whether the stream's identity changes during a session, which can indicate camera reboots or encoder resets.
Each RTP stream has a 32-bit SSRC identifier that uniquely identifies the source. This should remain constant throughout a session.
When SSRC changes after stabilization:
WARNING: SSRC changed (1 new sources after stabilization - possible camera reboot / encoder reset)
| 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 |
Shows how RTP packets are being transported from the camera to wink-rtsp-stats, helping diagnose connectivity and firewall issues.
| 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 (RTP Control Protocol) provides feedback and statistics:
RTCP provides:
Monitors RTP timestamp progression for discontinuities that may indicate stream interruptions or encoder issues.
| Metric | Description |
|---|---|
timestamp_jumps |
Large forward timestamp discontinuities |
timestamp_resets |
Backward timestamp jumps |
In Timing Analysis:
wink-rtsp-stats returns specific exit codes for CI/CD integration and scripting, enabling automated quality gates.
| 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 |
# 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
#!/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
Version 1.1 introduces a schema version field and units metadata for programmatic consumption.
{
"tool": "wink-rtsp-stats",
"version": "1.1.0",
"schema_version": "1.1",
...
}
The schema_version field allows consumers to handle format changes gracefully.
{
"_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"
}
}
{
"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"
}]
}
{
"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
}
}
Symptoms:
packets_lost_estimated increasingDiagnostic Steps:
transport_mode - try TCP if using UDPSolutions:
--transport tcpSymptoms:
jitter_ms_avg > 30msDiagnostic Steps:
Solutions:
Symptoms:
clock_drift_status: DRIFTING or UNSTABLEDiagnostic Steps:
Solutions:
Symptoms:
ssrc_stable: falseDiagnostic Steps:
Solutions:
Symptoms:
Diagnostic Steps:
Solutions:
# 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
# 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
# From file wink-rtsp-stats monitor --file cameras.txt --duration 30s # Limit concurrent wink-rtsp-stats monitor --file cameras.txt --max-streams 10
# Listen on UDP port without RTSP wink-rtsp-stats rtp --port 15002 --duration 30s
| 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 |
| 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 |