top of page

Adding AI to Existing CCTV: RTSP Streams, Recorder Limits and Where the Edge Box Goes

Writer: Srihari Maddula
Srihari Maddula
7 hours ago
16 min read
A security camera mounted on a weathered concrete building
Most installed cameras were placed to record evidence, not to feed a detection model, and the difference shows up in angle, height and pixels per metre. Photo: Turquo Cabbit on Unsplash

The analytics pilot at the warehouse went live on a Monday. Forty-eight existing cameras, an intrusion and safety-gear detection model, and an edge box in the server room pulling every camera's main stream through the network video recorder. The dashboard looked good by lunchtime. On Thursday, a forklift clipped a racking upright, and the security manager went to the recorder for the footage. Three cameras had gaps of several minutes across the morning. The recorder had been asked to stream out 48 full-resolution feeds while recording 48 more, and when it ran short of capacity, it had quietly dropped recording frames.

Nothing in that installation was broken. Each part was doing what it was designed to do. The recorder was built to record and to serve a few live views, not to act as a video distribution server for an AI system. The analytics were designed for clean streams, not for whatever the recorder had left over. And nobody had added up the numbers before switching it on.

This field guide walks through that chain from lens to alert, one link at a time: what to record about each camera, how streams are reached, why the recorder is so often the bottleneck, the network and decoding arithmetic, how many frames a model needs, why cameras installed for evidence often struggle with analytics, where the edge box should sit and how to size it, and how to make alerts that people act on. The warehouse is a composite scene, but every failure in it is common.

Adding AI to CCTV is a video distribution problem first and a model problem second. Get the streams right and most models work; get them wrong and none do.

The Chain From Lens to Alert

Every analytics deployment on existing cameras runs through the same links, and each can fail independently.

The camera captures and encodes video, usually into two or three streams at different resolutions. The stream travels over the site network, either directly from the camera or through the recorder. The edge box receives it, decodes it into raw frames, samples some of them, and runs a model. The model's detections pass through rules that turn them into events. Events go to people through a video management system, a dashboard, a message or an alarm panel, with a short clip attached as evidence. Throughout, the recorder keeps recording, untouched by any of this.

The last point matters most. The recorder's job is evidence, and analytics must never put that at risk. Every design choice below should be checked against it.


Start With an Inventory, Not a Model

Before choosing any analytics, collect a short record for every camera. It takes a day or two on a site of a few dozen cameras and prevents most surprises later.

Field

Why it matters

Location and purpose

What the camera was installed to see, and whether that matches the analytics

Make, model and firmware version

Determines stream options, ONVIF support and security patches

IP address, VLAN and switch port

Needed for direct access and for bandwidth planning

Main stream: codec, resolution, frame rate, bitrate

The load if analytics uses it

Substream and any third stream: same details

Often the better source for analytics

ONVIF profiles supported

Determines standard discovery and control

Mount height, tilt and horizontal field of view

Sets pixel density at the distances that matter

Day and night image quality

IR, glare and low light affect detection more than resolution

Recorder channel and recording settings

Shows what must be protected

A camera that is missing from the inventory, or whose settings nobody can confirm, will be the one that causes trouble during the pilot.


RTSP and ONVIF in Practice

Most IP cameras deliver live video over RTSP, the Real Time Streaming Protocol, with the video itself carried in RTP packets. Each manufacturer has its own URL path for each stream, and the same manufacturer often changes it between product lines, so the inventory should record the exact URL that works rather than a guessed pattern.

ONVIF is the industry standard that lets software discover cameras and ask them for their stream URLs, rather than relying on each manufacturer's conventions. Its profiles group features. Profile S, introduced in 2011, covered basic streaming; in October 2025 ONVIF announced it was ending support for Profile S, because its authentication mechanisms no longer meet current security recommendations, and encouraged users to move to Profile T. Profile T, introduced in 2018, covers advanced streaming including H.265, imaging controls and metadata. Profile M covers analytics metadata and events, including object classification and counting, and allows events to be sent over MQTT.

For an analytics project, ONVIF matters in three ways: discovery of stream URLs, standard configuration of the substream used for analytics, and, with Profile M, a standard way to send detections back to a video management system.

Two commands confirm a stream before any code is written. The first shows what the camera is sending; the second grabs a single frame to check the image:

# Inspect codec, resolution and frame rate of a stream (TCP transport avoids UDP loss)
ffprobe -rtsp_transport tcp -v error -select_streams v:0 \
  -show_entries stream=codec_name,width,height,avg_frame_rate,bit_rate \
  -of default=nw=1 "rtsp://USER:PASSWORD@192.168.10.21:554/STREAM_PATH"

# Save one frame to check framing, focus and exposure
ffmpeg -rtsp_transport tcp -i "rtsp://USER:PASSWORD@192.168.10.21:554/STREAM_PATH" \
  -frames:v 1 -q:v 2 cam21_check.jpg

Use a dedicated read-only account on each camera for analytics, not the administrator account the installer created.


Main Stream, Substream and Third Stream

Most cameras encode two streams at once, and many offer a third. The main stream carries full resolution for recording. The substream carries reduced resolution, typically 640 × 360 to 704 × 576, for live views on phones and multi-camera grids. A third stream, where available, can often be configured independently.

Many detection models run at input sizes of around 640 pixels on the long side. Feeding them a 4-megapixel main stream means decoding about 3.7 million pixels per frame to throw away more than 90 percent of them in resizing. A substream at 704 × 576 or a third stream at 1280 × 720 is often a better match, and it costs a fraction of the network and decoding load.

The main stream remains necessary in two cases: when the objects of interest are small or far away, such as a safety helmet at 25 m or a number plate, and when the analytics must crop a high-resolution region of a wide scene. In those cases, decode the main stream at a low frame rate, or crop only the region that matters.

Point the analytics at the substream or a configured third stream first. Move to the main stream only for cameras where the objects are too small to detect otherwise.

Why the Recorder Is Usually the Bottleneck

The tempting architecture is to pull every stream from the recorder, because it is one address, it already has every camera configured, and the cameras may sit on a network the analytics box cannot reach directly.

Recorders are built for a specific load: receiving and writing all their channels, plus serving a handful of live and playback views. Most specify a maximum incoming bandwidth and a separate, smaller maximum outgoing bandwidth for remote viewing. When an analytics system asks for every channel's main stream at once, the outgoing load can exceed that figure, and the recorder has to choose between serving the request and keeping up with recording. Some recorders limit outgoing streams; others degrade recording; few announce the problem clearly.

There are other recorder issues. Some recorders re-stream only the substream, or only a transcoded version. Some add latency of a second or more. Some charge licences for additional client connections. And when the recorder reboots, every analytics feed drops with it.

Approach

Advantages

Risks

Pull from the recorder

One address, cameras may be unreachable otherwise, credentials in one place

Outgoing capacity limits, recording risk, added latency, single point of failure

Pull directly from cameras

Recorder untouched, full control of streams, lower latency

Needs network access to camera VLAN, many credentials, cameras must support another client

Camera-side analytics

No stream transfer at all; events only

Limited models, varies by camera, older cameras lack it

Where the network allows it, pulling directly from cameras is almost always safer. Most cameras support several simultaneous stream clients, and the recorder carries on as before.


Network Arithmetic

The network numbers are simple and are frequently skipped. Our script estimates typical bitrates and loads for a site of 32 cameras. Real bitrates vary with scene activity, encoder settings and compression mode, so treat these as planning figures:

Stream type

Per-camera bitrate

32 cameras

Data per day at 32 cameras

4 MP main stream, H.265, 15 fps

About 4 Mbps

About 128 Mbps

About 1.4 TB

1080p main stream, H.264, 25 fps

About 6 Mbps

About 192 Mbps

About 2.1 TB

1080p, H.265, 15 fps

About 2.5 Mbps

About 80 Mbps

About 0.9 TB

D1 substream, H.264, 15 fps

About 0.75 Mbps

About 24 Mbps

About 0.26 TB

640 × 360 substream, 10 fps

About 0.4 Mbps

About 13 Mbps

About 0.14 TB

Two conclusions follow. Inside a site, a gigabit network can carry 32 main streams to an edge box, but if the cameras and recorder already share a congested switch uplink, the extra load can cause packet loss for recording too; check the switch ports and uplinks before adding traffic. Across a wide-area link to a central server or the cloud, main streams quickly become expensive or impossible, which is the strongest argument for processing on site and sending only events and short clips.


Decoding: The Hidden Load

Network bandwidth is only half the transport cost. Every compressed stream has to be decoded into raw frames before a model can use it, and decoding is often the real limit on how many cameras one box can handle.

Modern video codecs compress most frames as differences from earlier frames. To decode the frame you want, the decoder must decode every frame in between. Sampling five frames per second for analysis from a 25 fps stream therefore still means decoding all 25. The only frames that can be decoded alone are the periodic key frames, typically one every one to four seconds.

Edge AI modules include fixed-function video decoders, and their capacity is published as a number of streams at a given resolution. NVIDIA's published specifications, for example, list hardware decode for the Jetson AGX Orin 64GB at up to 22 streams of 1080p30 H.265, and for the Orin NX 16GB at up to 18. The same tables note that the Orin Nano has no hardware video encoder, which matters if the box must also produce clips. A comparison of accelerator options is in our earlier post on Jetson Orin and Hailo-8.

It helps to convert every stream into a common unit, megapixels per second. A 1080p30 stream is about 62 Mpix/s. Thirty-two 4 MP main streams at 15 fps come to about 1,770 Mpix/s, roughly 28 streams' worth of 1080p30, beyond the published decode capacity of even the largest module in that family. The same 32 cameras at D1 substream, 15 fps, come to about 195 Mpix/s, or about three 1080p30 equivalents.

Count decoder load in megapixels per second, and count every frame the camera sends, not just the frames the model uses. That single number decides how many cameras one box can take.

How Many Frames the Model Needs

Frame rate is the cheapest setting to change and the one most often left at the recording default.

Use case

Typical analysis rate

Notes

Intrusion in a restricted zone

2-5 fps

People take seconds to cross a zone

Safety gear checks at an entry point

2-5 fps

Several frames per person improve accuracy

Vehicle counting at a gate

5-10 fps

Depends on vehicle speed and field of view

Queue length or occupancy

0.2-1 fps

Changes over tens of seconds

Fire and smoke detection

1-2 fps

Persistence over several seconds reduces false alarms

Fast machinery or conveyor events

15-30 fps

Needs dedicated cameras, as our conveyor vision post explains

Where a camera offers a configurable third stream, setting its frame rate to the analysis rate reduces network and decoding load together. Where it does not, decoding only key frames is an option for slow use cases such as occupancy: with a key frame every two seconds, the decoder handles one frame every two seconds instead of fifty.


A Frame Grabber That Survives Real Cameras

Real camera streams drop, stall and restart. A grabber that assumes a clean stream will freeze or leak memory within days. The core needs a reconnect loop, a stall timeout, and sampling that discards frames rather than queuing them:

import time, cv2, os

os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;tcp|stimeout;5000000"

def frames(url, target_fps=5.0, stall_s=10.0):
    """Yield (timestamp, frame) at about target_fps, reconnecting on failure."""
    min_gap = 1.0 / target_fps
    while True:
        cap = cv2.VideoCapture(url, cv2.CAP_FFMPEG)
        if not cap.isOpened():
            time.sleep(5); continue
        last_yield, last_ok = 0.0, time.time()
        while True:
            ok = cap.grab()                      # decode-light: advance the stream
            now = time.time()
            if not ok:
                if now - last_ok > stall_s:
                    break                       # stalled: reconnect
                continue
            last_ok = now
            if now - last_yield < min_gap:
                continue                        # drop frames between samples
            ok, frame = cap.retrieve()
            if ok:
                last_yield = now
                yield now, frame
        cap.release()
        time.sleep(2)

# for ts, img in frames("rtsp://analytics_ro:PASSWORD@192.168.10.21:554/SUBSTREAM_PATH"):
#     detections = model(img)

This pattern is suitable for a pilot on a few cameras. For dozens of cameras, a pipeline built on hardware-decoding frameworks such as GStreamer or DeepStream moves decoding onto the dedicated hardware and keeps frames in device memory, which is where most of the per-camera capacity comes from.


Cameras Installed for Evidence, Not Analytics

Most existing cameras were placed by a security installer to record what happened, for viewing by a person afterwards. That often means wide fields of view, high mounting to avoid tampering, and angles chosen to cover as much area as possible. Those choices work for a human reviewing footage and can be poor for detection.

Pixel density is the measure that matters. The international standard for video surveillance system design, IEC 62676-4, defines categories by pixels per metre at the target: about 25 px/m to detect a person, 62 to observe, 125 to recognise a known person and 250 to identify an unknown one. A detection model for people needs roughly the detection-to-observation range; a model checking whether a person is wearing a helmet or a high-visibility vest needs more, closer to the observation-to-recognition range.

A 1080p camera with a 90-degree horizontal field of view sees a scene about 40 m wide at 20 m distance, giving about 48 px/m: enough to detect people and too little for reliable safety-gear checks. At 8 m, the same camera gives about 120 px/m. The practical effect is that safety-gear analytics often work only in the near part of an existing camera's view, and only a site walk with the inventory in hand shows which cameras are usable for which purpose.

Steep angles cause a second problem. A camera mounted high and looking down sees the tops of heads and helmets and little of the body, which many models were not trained on. Moderate angles, around 15 to 30 degrees below horizontal, suit most person-related analytics.


Night, Infrared and Glare

Daytime pilots succeed and night-time operation disappoints, more often than any other pattern in CCTV analytics.

At night, many cameras switch to infrared illumination and monochrome images. Colour-based features, such as high-visibility vest colours, disappear. Infrared illuminators create a bright zone near the camera and a dark zone beyond, so detection range shrinks. Reflective strips on vests and helmets can saturate in infrared and look like blobs. Insects and spiders near the illuminator create moving bright spots that trigger motion and detection.

Daytime has its own problems: direct sunlight into the lens at certain hours, strong shadows across doorways, and glare from wet floors or vehicle windscreens.

The answer is to test each candidate camera across a full day and night cycle before committing to it, and to collect validation images from the actual cameras at all times of day. A model that has never seen night-time infrared footage from the site will not perform well on it.


Where the Edge Box Sits

There are three common placements, and the right one depends on the network, the number of sites and the latency the use case needs.

Placement

Suits

Watch for

One box per site, in the server or network room

Sites with tens of cameras on a local network

Box sizing and cooling in a cramped rack

Small boxes per cluster of cameras, near the switches

Large sites with distant buildings or limited backbone capacity

More units to manage and update

Central server for several sites

Many small sites with good links and relaxed latency

Wide-area bandwidth and dependence on the links

For most industrial sites, one box per site with direct camera access is the starting point. It keeps video on the site, needs only events and clips to travel elsewhere, and keeps working when the internet link fails. Our earlier posts on fanless edge boxes in hot cabinets and on air-gapped AI cover the hardware and isolation sides of that choice.


Sizing an Edge Box: A Worked Example

Take a site with 32 cameras, of which 24 are suitable for intrusion and safety-gear checks after the site walk. Twenty of them run on D1 substreams at 15 fps for intrusion; four, covering entry points, run at 1080p for safety-gear checks.

The decoder load is about 20 × 6.1 = 122 Mpix/s for the substreams, plus about 4 × 31 = 124 Mpix/s if the four entry cameras run 1080p H.265 at 15 fps: about 246 Mpix/s, or four 1080p30 equivalents. That is comfortably within the decoders of mid-range edge modules.

The inference load depends on analysis rate. At 5 fps across 24 cameras, the model runs 120 times per second. A detection model at 640 pixels that runs at, say, 300 frames per second on the chosen accelerator, at the precision used in production, has headroom of about 2.5 times for a second model, tracking, and growth. The model's measured throughput on the target hardware, not a benchmark from another platform, is the figure to use.

Memory, storage and power follow: enough memory for the decode buffers and models, local storage for event clips and a rolling buffer, and a power and cooling budget for the cabinet. A box sized at 50 to 70 percent of its decode and inference capacity at launch leaves room for the cameras that will be added once the first results are seen.


Alerts People Act On

The output of an analytics system is a decision by a person, and most deployments fail here rather than in the model.

An alert should arrive where the responsible person already looks: the video management system if there is a security control room, a messaging app for a shift supervisor, an alarm panel for a guard house. It should carry a short clip or a still with the detection marked, the camera name and location, and the time, so the person can judge it in seconds. ONVIF Profile M and MQTT both offer standard ways to deliver such events to other systems.

Rules turn detections into alerts. A person detected in a restricted zone for one frame is noise; a person in the zone for three seconds during a closed shift is an alert. Zones, schedules, minimum durations, and cooling-off periods after an alert all reduce false alarms.

Alert volume needs managing from the first day. If a camera produces dozens of false alerts a shift, operators stop looking at all of them within a week. Track alerts per camera per day, review false alerts weekly, and fix the camera, the zone or the rule before adding more cameras.

Measure false alerts per camera per day from the first week. When that number climbs, people stop looking, and a system nobody looks at protects nobody.

Storage and Retention for Analytics Clips

The recorder keeps the continuous footage. The analytics system needs its own, much smaller store: event clips of a few seconds before and after each alert, still images, and the metadata for each detection.

Clip generation requires either a short rolling buffer of decoded or compressed video on the edge box, or a request to the recorder for the clip after the event. The rolling buffer is more reliable and keeps the recorder out of the analytics path. Retention should be set by policy: long enough for investigations and model improvement, short enough to limit the personal data held. Clips used to retrain models need their own consent and retention rules.


Securing an Old CCTV Network

Many existing CCTV networks were installed with default passwords, outdated firmware and flat networks shared with office devices. Adding analytics, which needs access to every camera, is a good moment to fix that.

Put cameras, the recorder and the edge box on a dedicated VLAN, with no direct internet access for cameras. Change default credentials and create a read-only account for analytics. Update camera and recorder firmware where the manufacturer still supports the model. Prefer Profile T and TLS where the cameras support them, given ONVIF's guidance on Profile S authentication. Send events out from the edge box over an outbound, authenticated connection, rather than opening inbound ports to the site.


Privacy Belongs in the Design

Analytics changes what CCTV footage is used for. Footage that was recorded for security and reviewed only after incidents becomes a continuous stream of automated observations about people. That raises privacy obligations under data protection law, including India's Digital Personal Data Protection Act, and under workplace agreements.

Practical design choices reduce the risk: limit analytics to the purposes stated to staff and visitors, avoid identification features unless they are required and lawful, mask areas such as private spaces and public roads, keep video on site, store events rather than continuous analysed footage, and set clear retention periods. A notice that explains what the system does and why is part of the deployment, not an afterthought.


What to Measure During the Pilot

A pilot is only useful if it produces numbers that decide the production design. Four groups of measurements cover most of what matters, and each can be logged automatically from the first day.

Recorder health comes first, because it is the one thing the analytics must not damage. Check recording continuity for every pilot camera every day, using the recorder's own logs or a script that requests the last 24 hours of footage and looks for gaps.

Transport comes next: stream reconnections per camera per day, average and peak bitrate per stream, and packet loss on the switch ports involved. A camera that reconnects dozens of times a day points to a network or firmware problem that will multiply at scale.

The edge box follows: decoder utilisation, inference throughput, end-to-end latency from frame capture to alert, temperature, and memory use over several days, which reveals slow leaks.

Detection quality comes last and matters most: true detections, false alerts and missed events, counted separately for day and night, for each camera. Missed events need a ground truth, which usually means a person reviewing a sample of recorded footage against the alert log.

Measurement

Healthy pilot

Investigate

Recording gaps on pilot cameras

None

Any gap at all

Stream reconnections per camera per day

0-2

More than 10

Decoder utilisation at peak

Below 70%

Above 85%

Capture-to-alert latency

Under 2-3 seconds for safety use cases

Rising over days, or over 5 seconds

False alerts per camera per day

A handful, falling as rules are tuned

Dozens, or rising

Night-time detection rate compared with day

Within a modest margin

Much lower at night

Log recorder continuity alongside every analytics metric. A pilot that improves detection and quietly costs evidence has failed, however good its dashboard looks.

A Rollout Sequence

First, complete the camera inventory and a day-and-night site walk, and classify each camera as suitable, suitable after adjustment, or unsuitable for each use case. Second, confirm network access to cameras, measure switch and uplink load, and set up read-only accounts. Third, configure substreams or third streams for analysis resolution and frame rate. Fourth, run a pilot on four to eight cameras with the edge box pulling directly from cameras, checking recorder health daily. Fifth, measure detection quality and false alerts on real footage across a full week, including nights. Sixth, size the production box from measured decode and inference load. Seventh, roll out in groups, tuning zones and rules per camera, and keep tracking false alerts per camera per day.


Back to the Warehouse

The forklift footage was lost because the analytics system borrowed capacity from the recorder without anyone adding up what it needed. The model itself was fine.


Pulling substreams directly from the cameras, at a frame rate matched to each use case, would have cut the load to a small fraction and left the recorder alone. The same inventory, arithmetic and site walk would have shown which of the 48 cameras could support safety-gear checks at all, and which should only watch for intrusion.

EurthTech is an engineering-first product design and embedded systems company with a development center in Hyderabad. To discuss a project, write to connect@eurthtech.com or see https://www.eurthtech.com/case-studies.

Comments


EurthTech delivers AI-powered embedded systems, IoT product engineering, and smart infrastructure solutions to transform cities, enterprises, and industries with innovation and precision.

Factory:

Plot No: 41,
ALEAP Industrial Estate, Suramapalli,
Vijayawada,

India - 521212.

  • Linkedin
  • Twitter
  • Youtube
  • Facebook
  • Instagram

 

© 2026 by Eurth Techtronics Pvt Ltd.

 

Development Center:

4th Floor, Krishna towers, 100 Feet Rd, Madhapur, Hyderabad, Telangana 500081

Menu

|

Accesibility Statement

bottom of page