Research deep-dive / Video infrastructure
RTSP stream optimization for video AI workloads
RTSP stream optimization means choosing the right stream, codec, resolution, frame rate and transport for each analytics task rather than accepting camera defaults. On a retrofit site it typically cuts decode load and bandwidth by an order of magnitude, because most detection work needs far less video than recording does.
Most analytics deployments on existing camera estates are sized wrongly, and almost always in the same direction. An appliance is specified against the number of cameras, connected to the recorder, pointed at whatever stream the recorder offers first, and then found to be undersized. The diagnosis is usually recorded as insufficient compute. The actual cause is that the system was asked to decode far more video than the task required.
This deep-dive works through the five decisions that determine how much video a system actually has to handle: which stream, what resolution, which codec, how many frames per second, and which transport. Each is examined against published standards and peer-reviewed measurement rather than vendor guidance, because vendor defaults are set for recording and human review, not for machine consumption.
What RTSP controls, and what it does not
The first source of confusion is the protocol itself. RTSP is a control protocol. It negotiates a session and carries commands such as DESCRIBE, SETUP, PLAY, PAUSE and TEARDOWN. The media travels separately, normally over RTP, defined in RFC 3550. RTSP 2.0, specified in RFC 7826 and published in December 2016, formally obsoletes the original RFC 2326 from 1998.
RFC 7826 is explicit that the protocol deliberately avoids assuming anything about the media it controls. The specification states that RTSP exists to provide access to multimedia content but tries to be agnostic about the media type and the delivery protocol used. That agnosticism is why the same protocol serves a doorbell camera and a broadcast contribution feed, and also why the interesting engineering decisions all sit outside RTSP itself.
The practical consequence is that a session can negotiate perfectly over RTSP and still deliver no usable video, because the failure is in the media path. It also means that RTSP itself is almost never the bottleneck. What matters is what you asked the camera to encode.
Decision one: which stream
Nearly every IP camera published in the last decade encodes the same sensor output two or three times simultaneously and publishes each encoding at a different RTSP path. A typical configuration offers a main stream at 1920x1080 and 25 fps, and a sub stream at 640x360 and around 10 fps.
The recorder consumes the main stream because recording is an evidentiary function. Analytics has no such requirement, and the difference in cost is substantial.
Worked example: decode and bandwidth cost per camera
Sub stream: 640 x 360 = 230,400 px per frame, at 10 fps = 2.3 Mpx/s
Pixel throughput ratio = 51.8 / 2.3 = 22.5 to 1
Typical encoded bitrate, main: 2 to 4 Mbps
Typical encoded bitrate, sub: 0.3 to 0.5 Mbps
Bandwidth ratio ≈ 7 to 1
Note that the two ratios differ, and the difference matters. Bandwidth scales at roughly 7 to 1 because compression efficiency improves with resolution, but decode and inference load scale closer to 22 to 1 because they track raw pixel throughput. An appliance sized on bandwidth will be undersized on compute. This is the single most common sizing error in retrofit deployments.
Decision two: how much resolution the task needs
The instinct that more resolution is safer produces systems that cost several times what they need to. The disciplined alternative is to specify against the operational task, which is exactly what IEC 62676-4, the application guidelines part of the video surveillance standard, exists to do.
The standard anchors named operational tasks to a minimum pixel density on the target plane, expressed in pixels per metre. The classic four-step DORI ladder sets detection at 25 px/m, observation at roughly 63 px/m, recognition at 125 px/m and identification at 250 px/m. The model derives from the number of pixels needed across a human face, taking an average face width of 16 cm.
The 2025 revision of IEC 62676-4 adds a finer seven-step ladder alongside the original four, running from Overview at 20 px/m through Outline, Discern, Perceive, Characterise and Validate to Scrutinise at 1500 px/m. The four DORI thresholds are unchanged, so existing designs remain valid.
| Task | Pixel density | Analytics implication |
|---|---|---|
| Overview (2025 ladder) | 20 px/m | Sufficient for many alarm-triggering analytics based on moving objects, such as perimeter tripwires. |
| Detection | 25 px/m | Person and vehicle presence. Adequate for counting and zone occupancy. |
| Observation | 63 px/m | Posture, clothing contrast, general activity. Supports appearance-based matching. |
| Recognition | 125 px/m | Matching a known individual. Around the practical floor for reliable PPE item detection. |
| Identification | 250 px/m | Identity beyond reasonable doubt. The evidentiary threshold in many jurisdictions. |
| Scrutinise (2025 ladder) | 1500 px/m | Passport-grade capture, and clear reading of vehicle plates assuming acceptable motion blur. |
Two conclusions follow, and they point in opposite directions.
The first is that a great deal of analytics work sits at the bottom of this ladder. If the task is to know that a person entered a zone, the standard puts the requirement at 20 to 25 px/m. A 640x360 sub stream covering a 10 metre wide scene delivers 64 px/m, comfortably above detection and into observation. Running that task on a main stream is spending twenty times the compute for no gain in outcome.
The second is that plate reading and face work sit at the very top and cannot be served by a sub stream at all. The 2025 Scrutinise tier at 1500 px/m is an order of magnitude above what a general surveillance camera delivers at typical standoff distances. This is why ANPR normally requires a dedicated, tightly framed camera per lane rather than a share of an existing wide view.
A note on our own published figures. IndoAI has previously derived an ANPR requirement of roughly 300 px/m from a target OCR character height of 20 pixels on a 65 mm character. That derivation addresses what an OCR model needs, which is a different question from what IEC 62676-4 specifies for a human operator reading a plate with certainty. The two numbers are not interchangeable and we are reconciling them. Where the two disagree, specify against the standard, because it is the figure an auditor or an insurer will apply.
Decision three: codec, and why the fifty percent headline misleads at 1080p
H.265, also called HEVC, is widely described as delivering the same quality at half the bitrate of H.264. That claim has a solid provenance. The JCT-VC verification testing programme in 2013 measured an average bitrate saving of around 50 percent at matched Mean Opinion Score. A BBC research team examining ultra high definition content found an average saving of 59 percent when judged subjectively, against 44 percent when judged by objective PSNR-based metrics.
Both figures are real, and both are misleading when applied to video surveillance, for a reason that is easy to miss: the saving depends heavily on resolution, and it is smallest at the resolutions surveillance actually uses.
A 2024 comparison of VVC, AV1, HEVC and AVC across high resolutions found that the bitrate savings between HEVC and H.264 start at around 14 percent at full HD and rise to roughly 77 percent at 8K.
What this means for a 1080p camera estate
Measured saving at full HD: from about 14%
Estate of 64 cameras at 1080p, 3 Mbps H.264 = 192 Mbps
At an optimistic 30% H.265 saving = 134 Mbps
At the measured FHD figure of 14% = 165 Mbps
The difference between the marketing number and the measured number at your actual resolution is 31 Mbps on this estate, which is the difference between a plan that works and one that does not. H.265 is still worth enabling where the cameras and the decoder both support it. Sizing a network on a 50 percent saving at 1080p is planning against a figure that was measured at 4K and above.
There is a second consideration specific to analytics. H.265 decode is more computationally expensive than H.264. On an edge appliance without hardware HEVC decode, moving the estate to H.265 saves network bandwidth and spends compute, which on a device already constrained by decode is the wrong trade. Verify hardware decode support for the specific codec and profile before switching an estate over.
Decision four: frame rate
Frame rate is the cheapest optimisation available and the most frequently overlooked. Analytics load scales close to linearly with frames analysed, and most tasks do not need every frame.
Sampling guidance by task type, assuming typical indoor and gate scenarios:
| Task | Practical sampling | Why |
|---|---|---|
| Zone occupancy, people counting | 3 to 5 fps | A walking person crosses a doorway over several hundred milliseconds, which is many frames at 5 fps. |
| PPE compliance | 5 to 10 fps | Persistence rules need several consecutive frames to suppress false findings. |
| Perimeter intrusion | 5 to 10 fps | Path coherence across frames is what separates an intruder from an insect. |
| Fall detection | 10 to 15 fps | The transition is fast and the pose sequence carries the signal. |
| Plate reading at speed | 25 fps or higher | Multi-frame voting needs many attempts within a short window of approach. |
Dropping an estate from 25 fps to 5 fps for detection tasks reduces analytic load by a factor of five, on top of any saving from stream selection. Combined with the 22 to 1 pixel throughput ratio from sub stream selection, the compound effect on a detection-only workload is large enough to change the hardware class required.
Decision five: transport
RTP can travel over UDP or be interleaved within the RTSP TCP connection. The trade is conventionally described as latency against reliability, and the conventional description is incomplete.
RFC 7826 is notably cautious about interleaving. The specification advises that interleaving should generally be avoided unless necessary, because it complicates operation and adds overhead, and it warns that head-of-line blocking may cause problems.
For a human watching a monitor, that guidance is sound. For analytics, the calculus shifts, because the two failure modes have very different consequences. A dropped frame under UDP is a missed detection opportunity. A delayed frame under TCP is a detection that arrives late. In most analytics tasks other than real-time control, late is recoverable and missing is not.
There is also a finding from the measurement literature that runs against intuition. A 2023 study in Sensors compiled a dataset of 11,200 full HD and ultra HD sequences encoded in H.264 and H.265 at five bitrates, with simulated packet loss from 0 to 1 percent, and assessed them both objectively and subjectively. Alongside the expected result that quality falls as loss rises, the authors found that the quality of sequences affected by packet loss declines with increasing bitrate.
Read that carefully, because it inverts a common assumption. On a lossy network, raising the bitrate can make the delivered result worse, not better. A higher bitrate stream carries more information per packet, so each lost packet destroys more, and the damage propagates further through subsequent predicted frames. The instinct to fix a poor-looking stream by increasing bitrate is, on a congested link, precisely wrong. Fix the loss, or lower the bitrate.
This matters for analytics because a corrupted frame does not merely look bad, it produces detections that are wrong rather than absent, which is considerably harder to notice in an alert log than a gap.
The constraint that surprises people: concurrent connections
Every optimisation above assumes the appliance can open the streams it wants. Cameras impose a limit on simultaneous RTSP sessions, commonly between four and twenty depending on model and firmware, and the NVR already occupies one. Older cameras sit at the low end of that range.
NVR re-streaming is frequently more constrained than the cameras behind it, sometimes capped well below the channel count. Establish the limit during survey, not during commissioning, because exceeding it produces intermittent failures that present as network problems and are diagnosed slowly.
Security, and the gap between the specification and the field
RTSP 2.0 tightened security materially over RTSP 1.0. RFC 7826 mandates TLS support, requires both Basic and Digest authorisation to be supported, and requires that agents handling RTP media implement Secure RTP as defined in RFC 3711.
Almost no deployed surveillance estate reflects this. The overwhelming majority of installed cameras speak RTSP 1.0 with credentials embedded in the URL and media in the clear. An independent assessment of the protocol family observes that basic RTSP is suitable only for local managed networks, having no packet loss recovery, dynamically negotiated UDP ports and poor firewall behaviour.
The operational conclusion is not to replace the estate. It is to place it on an isolated VLAN with no inbound internet route, to reach it from analytics inside that segment rather than through a port forward, and to issue per-consumer credentials so a decommissioned system can be revoked without rotating the camera password and rediscovering everything that used it.
Putting it together
Worked example: a 64 camera site, before and after
64 x 1920 x 1080 x 25 fps = 3,318 Mpx/s decode
64 x 3 Mbps = 192 Mbps sustained
AFTER: detection on sub stream at 5 fps, main pulled on event
64 x 640 x 360 x 5 fps = 74 Mpx/s decode
64 x 0.4 Mbps = 26 Mbps sustained
plus 2 concurrent main streams on event = 6 Mbps
Decode load reduction = 3,318 / 74 ≈ 45x
Sustained bandwidth = 192 / 32 ≈ 6x
A 45-fold reduction in decode load is the difference between a rack server and a fanless appliance. These are arithmetic on stated assumptions, not a measured result at any specific site. Camera bitrates vary with scene complexity, and variable bitrate encoding means the sustained figure moves with activity. Measure your own estate before committing to a hardware class.
The general principle is that continuous work should be cheap and expensive work should be rare. Detection runs constantly and therefore runs on the cheapest stream that satisfies the pixel density requirement for the task. Evidence capture runs occasionally and can afford the main stream. Designing the two paths separately, rather than running everything at recording quality, is what makes analytics on an existing estate economically sensible.
For the architectural argument behind processing on site at all, see our note on edge AI. For the protocol mechanics in brief, see RTSP, and for discovery across a mixed estate, ONVIF.
Frequently asked questions
Should analytics always use the sub stream?
For tasks at or below the observation threshold of about 63 px/m, yes, because it costs roughly a twentieth of the decode load for no loss of outcome. Tasks at recognition and above, meaning 125 px/m or more, cannot be served by a typical sub stream. Plate reading in particular sits far higher and normally requires a dedicated camera framed for the lane.
Why is decode load reduced more than bandwidth when switching to a sub stream?
Because they scale on different quantities. Bandwidth tracks the encoded bitrate, and compression efficiency improves with resolution, so the ratio is around seven to one. Decode and inference track raw pixel throughput, which for 1920x1080 at 25 fps against 640x360 at 10 fps is about twenty two to one. Sizing an appliance on the bandwidth ratio underestimates the compute needed.
Does H.265 really halve bandwidth compared with H.264?
At ultra high definition, roughly yes. The 2013 JCT-VC verification tests measured around 50 percent at matched perceptual quality, and a BBC study of UHD content found 59 percent subjectively. At full HD, which is what most surveillance estates run, measured savings begin far lower, from around 14 percent in a 2024 multi-codec comparison. Plan against the figure for your actual resolution.
Is H.265 always the right choice for analytics?
Not necessarily. H.265 decode is more computationally expensive than H.264, so on an appliance without hardware HEVC decode you save network bandwidth and spend compute, which is the wrong trade if decode is already your constraint. Confirm hardware decode support for the specific codec and profile before converting an estate.
What frame rate does video analytics actually need?
Less than most deployments use. Zone occupancy and counting work at 3 to 5 fps. PPE compliance and perimeter intrusion sit around 5 to 10 fps, because persistence and path coherence rules need several consecutive frames. Fall detection benefits from 10 to 15 fps. Plate reading at speed is the outlier and needs full rate for multi-frame voting.
Should RTP run over TCP or UDP for analytics?
TCP is usually the better default for analytics, because a missing frame is a missed detection while a slightly delayed frame is not. RFC 7826 cautions that interleaving adds overhead and can cause head-of-line blocking, which is sound guidance for live human viewing. Where the output drives a barrier or interlock, latency matters more and UDP is preferable.
Does raising the bitrate improve a stream that looks poor?
On a congested or lossy link, no, and it can make matters worse. A 2023 study across 11,200 encoded sequences found that quality under packet loss declines as bitrate rises, because each lost packet destroys more information and the damage propagates through subsequent predicted frames. Address the loss, or reduce the bitrate.
What is DORI and why does it matter for machine vision?
DORI is the four-step ladder in IEC 62676-4 anchoring detection, observation, recognition and identification to pixel densities of 25, 63, 125 and 250 px/m on the target. It matters because it converts a vague requirement into a measurable one, and because it usually shows that detection tasks need far less resolution than the estate is currently supplying them.
What changed in IEC 62676-4:2025?
The revision adds a parallel seven-step ladder alongside DORI, running Overview 20, Outline 40, Discern 80, Perceive 125, Characterise 250, Validate 500 and Scrutinise 1500 px/m. The four original DORI thresholds are unchanged, so existing specifications remain valid. The new tiers give finer targets both below detection for wide-area awareness and above identification for biometric-grade capture.
How many RTSP streams can one camera serve simultaneously?
Typically between four and twenty depending on model and firmware, with the NVR already consuming one. Older cameras sit at the low end. NVR re-streaming is often more restricted than the cameras behind it. Establish the limit during site survey, because exceeding it produces intermittent failures that get misdiagnosed as network faults.
Is RTSP secure?
RTSP 2.0 mandates TLS support and requires Secure RTP for agents handling media. Deployed estates rarely reflect this, since most installed cameras speak RTSP 1.0 with credentials in the URL and media unencrypted. The practical mitigation is network segmentation: an isolated camera VLAN with no inbound internet route, analytics reaching it from inside that segment, and per-consumer credentials.
Can these optimisations be applied without touching the recording setup?
Yes, and that is the point of the dual path pattern. The recorder continues consuming the main stream exactly as before, while analytics consumes the sub stream as an additional client. Nothing about the evidentiary recording changes. The only prerequisite is that the estate has concurrent connection headroom for the extra consumer.
References
- Schulzrinne, H., Rao, A., Lanphier, R., Westerlund, M., and Stiemerling, M. (Eds.), Real-Time Streaming Protocol Version 2.0, RFC 7826, IETF, December 2016.
- Schulzrinne, H., Casner, S., Frederick, R., and Jacobson, V., RTP: A Transport Protocol for Real-Time Applications, RFC 3550, IETF, July 2003.
- IEC 62676-4, Video surveillance systems for use in security applications, Part 4: Application guidelines. Pixel density thresholds summarised in Axis Communications, Pixel density based on IEC 62676-4:2014.
- Bienik, J., Uhrina, M., Sevcik, L., and Holesova, A., Impact of Packet Loss Rate on Quality of Compressed High Resolution Videos, Sensors, 2023. DOI 10.3390/s23052744.
- Catellier, A., et al., Characterization of the HEVC Coding Efficiency Advance Using 20 Scenes, NTIA Institute for Telecommunication Sciences, IEEE ISM 2015.
- Performance Comparison of VVC, AV1, HEVC, and AVC for High Resolutions, Electronics, 13(5), 953, MDPI, 2024.
- BBC R&D subjective testing of HEVC against AVC for UHD content, as reported in 2015.
Sizing analytics against an existing camera estate?
IndoAI surveys what your cameras and recorder actually expose, then specifies the stream, sampling rate and transport per task rather than running everything at recording quality. Send us your camera list and NVR model.
Talk to an adviserReviewed by Dr. Vivek Gujar, Chief Strategy Officer at IndoAI Technologies Pvt. Ltd., a Pune-based edge AI camera platform founded in 2021. He reviews IndoAI's published technical claims for accuracy. Profile