Low-bitrate CCTV and AI: getting usable detections

AI detection holds up under moderate CCTV compression but fails on small, dark or fast targets at low bitrates. Fix pixels on target first, then the stream.

By CloudOEngine.ai Engineering · · 12 min read

You can get usable AI detections from low-bitrate CCTV, because modern detectors tolerate a lot more compression than people expect: in one study, cutting the bitrate by about seven times barely changed detection scores. What they do not tolerate is a target that is too small, too dark or moving too fast for the few bits left to describe it. So fix how many pixels land on each person or vehicle first, then the stream settings, and only then the model.

Most companies that want analytics already own the cameras. They were bought for security, mounted for a guard to glance at, and set to a bitrate that lets the recorder keep 30 days of footage on the disk it shipped with. Nobody chose those settings with a neural network in mind. The good news is that a lot of it is fixable without new hardware, if you work through the problem in the right order.

How much compression a detector actually tolerates

The most useful measurement I know of comes from O'Byrne and colleagues (2022). They took 50 surveillance videos, annotated the people, bikes and vehicles, encoded each one with H.264 at five quality levels and ran a widely used open-source detector (YOLOv5) on every version. The quality setting they varied is called the Constant Rate Factor (CRF): higher numbers mean more compression. Their summary table is worth reading in full.

H.264 CRF Average bitrate (Mb/s) VMAF (visual quality, 0-100) Detection F1
22 2.32 96.58 0.89
32 0.63 88.19 0.90
37 0.34 79.38 0.89
42 0.19 67.49 0.84
47 0.12 53.16 0.76

From 2.32 to 0.34 megabits per second, the bitrate fell by roughly seven times and the F1 score did not move. The visual quality score dropped by 17 points over the same range, which tells you something important: footage that looks noticeably worse to a person can be just as good for a detector. The authors put it plainly: using CRF 37 instead of 22 "leads to significantly reduced bitrates/file sizes without adversely affecting detection performance".

Below that, it falls off. At 0.19 Mb/s the F1 score is 0.84, and at 0.12 Mb/s it is 0.76. The losses were not spread evenly either. Bikes suffered most, which the authors put down to their thin, fine structure being wiped out by the encoder, while vehicles kept their general shape. Dark night scenes, unevenly lit scenes and fast-moving vehicles were hit hardest. And small objects went first: in their words, "as compression increases, the minimum object size that we can reliable detect also rises".

This lines up with older work on still images. Dodge and Karam (2016) tested four image classification networks against five kinds of distortion and found them "surprisingly resilient" to JPEG compression until the quality setting fell below about 10, while blur and noise hurt all of them. That second half matters for CCTV, because blur (from motion and focus) and noise (from low light) are exactly what night footage has more of.

One caveat about the table. Bitrate depends on resolution, frame rate and scene, and those test videos were mostly not 4K. Don't read 0.34 Mb/s as a safe number for your cameras. Read the shape of the curve: flat for a long way, then a cliff, and the cliff arrives sooner for small, dark and fast targets.

Pixels on target matter more than the bitrate

If small objects fail first, the first question is how small your targets are by the time they reach the model. Two things shrink them that people forget.

The first is the camera's view. A camera covering a whole car park from a pole makes each person tiny, however many megapixels it has. The UK government's police guidance for CCTV systems makes the same point for evidence footage: the right resolution, compression and frame rate depend on what the system must capture, and the way to confirm it is a subjective test on the real scene. The same logic applies to AI. Decide what the detector must see, then check it on your footage.

The second is the resize inside the detector. Most detectors work on a fixed input size, often a few hundred pixels across, so a full HD frame is scaled down before the model ever sees it. As an illustration: a 1920 x 1080 frame scaled to 640 pixels wide shrinks everything by three times. A person who is 60 pixels tall and 24 wide in the original becomes 20 by 8. The standard COCO benchmark code counts any object with an area under 32 x 32 pixels as "small", and small objects are what the compression study above lost first. You bought a 1080p camera, and the model is looking at something closer to a thumbnail.

This is why the cheapest fix is often in the software, not the camera. If the people you care about only appear in one part of the frame (an entrance, a lane, a loading bay), crop that region at full resolution and send only the crop to the detector. Or split a wide frame into overlapping tiles and run the detector on each. Both cost more compute per frame but put real pixels back on the target. I would try a crop before I would try a bigger model.

Where the detail goes missing

It helps to follow a single frame from the scene to the tracker, because each stage can lose detail and each has its own fix.

Where a CCTV frame loses detail before the model decidesCamera viewlens, angle, lightEncoderbitrate, streamNetworkRTSP, packetsResizeto model inputDetect +trackWhat it losestiny, darktargetsthin edges,fast motiongrey smearstill keyframe60 px personbecomes 20 pxgaps becomeID switchesThe leveraim, zoom,add lightmain stream,sane bitratepull over TCP,watch dropscrop or tilethe regiontracker tuning,human reviewIllustration. Work left to right: a fix early in the chain is cheaper than a better model at the end.
Each stage between the scene and the tracker can throw detail away, and each has its own lever. The resize step is the one most teams forget.

The encoder stage has a trap of its own: the substream. Most IP cameras send two or more streams at once, a main stream at full resolution for recording and a much smaller substream for live grids and phone apps. Analytics software often connects to the substream by default because it is cheap to decode. That is fine for a close doorway view where a person fills a third of the frame, and terrible for a wide yard. Check which stream your analytics is actually pulling, and read the real bitrate and resolution from the stream itself (ffprobe will tell you), not from the camera's spec sheet.

Many recorders also use variable bitrate modes that drop the bitrate sharply when the scene is still and raise it when something moves. That is sensible for storage, but it can mean the first second of a person walking into an empty corridor is the worst-encoded part of the clip, exactly when the detector needs to pick them up.

Smearing is a network problem, not a model problem

Compressed video sends a full picture (a keyframe) only every so often and describes the frames in between as changes from earlier ones. Lose a packet from one of those frames and the decoder keeps building on a damaged picture, which is the grey smear or blocky trail you see on some live feeds, until the next keyframe resets it. A detector fed those frames will miss people inside the smear, and a tracker will lose them and pick them up again under a new ID.

RTSP streams can be carried over UDP or TCP, and tools such as FFmpeg let you choose with an rtsp_transport option. UDP drops lost packets; TCP resends them, at the cost of some delay when the link is congested. For analytics on a site network that drops packets, TCP is usually the better trade. Either way, log decoder errors per camera, because a camera that produces smeared frames for ten minutes every evening will quietly drag down your accuracy and nobody will look at the raw feed to notice.

If the uplink itself is what forces the low bitrate, there is research on spending bits where the model needs them. The DDS system (Du and colleagues, SIGCOMM 2020) sends a low-quality stream to the server, lets the server's detector decide which regions it is unsure about, and has the camera side re-send only those regions at higher quality. Against the baselines they tested, the authors report up to 59% less bandwidth at higher accuracy. It is a research design rather than something you switch on in a recorder, but the principle carries over: a low-quality stream for finding things, and a higher-quality look only where it matters. Our article on edge vs cloud video analytics covers when to move the detector to the site instead.

Night footage is a separate test set

Low bitrate and low light compound each other. At night, a camera either raises its gain, which adds noise, or switches to infrared and gives you a monochrome picture with a bright centre and dark edges. Noise is expensive to compress, so at a fixed bitrate the encoder smears more. And noise is exactly the distortion Dodge and Karam found that networks handle worst.

The training data does not help much either. Loh and Chan built the Exclusively Dark dataset (7,363 low-light images across 12 object classes and ten kinds of lighting) partly because low-light images make up less than 2% of major datasets such as PASCAL VOC, ImageNet and COCO. A general-purpose detector has seen very few people under a sodium streetlight.

So treat night as its own test. Pull an hour of footage from 7pm and an hour from 2am for every camera you plan to use, and measure detection on those separately from daytime. A white light or an extra infrared illuminator over the area that matters can do more than any software change.

Model-side fixes, and how much to expect

Once the camera, stream and network are as good as you can get them, there are things to try on the model side. Expect modest gains.

Retraining on compressed footage helps a little. O'Byrne's team retrained their detector on compressed surveillance video and got up to a 1% improvement in F1 on the most compressed footage. Worth doing if you have labelled examples from your own cameras, not worth waiting for.

Super-resolution (upscaling frames with a model before detection) sounds like the obvious answer to "too few pixels", and it can help. The clearest test I found is on satellite imagery rather than CCTV: Shermeyer and Van Etten found super-resolution improved detection most when applied to the sharpest imagery they had (a 13-36% gain in mAP) and helped much less on coarse images. The pattern is what you would expect. Super-resolution sharpens detail that is faintly there; it cannot recreate detail the encoder discarded. On heavily compressed footage it may also invent texture, so check it against ground truth before trusting it.

Lowering the detection confidence threshold catches more faint targets and also more false ones. That trade is better handled downstream, by the tracker and by people, than by guessing a threshold. A missed detection in one frame is not a missed person if the tracker can carry the track across a short gap, and tuning how long a track survives without a detection matters more on poor footage than on clean footage. Our article on video analytics accuracy covers ID switches and double counts in detail.

When a single tracker has to guess through bad frames, it guesses wrong without telling anyone. CloudOEngine's Vision AI counts with two independent trackers, and where they disagree, the case goes to a human review queue where your staff check it, so the worst-encoded moments get a person's eyes instead of a silent guess.

Measure on your own footage

Every number in this article came from someone else's cameras. The only way to know what your footage supports is to test it, and the test is not hard.

  1. Pick the cameras you plan to use and record 15 to 30 minutes from each at the busiest time of day and at night, from the main stream, at the highest bitrate the camera allows.
  2. Have a person label the targets you care about (people crossing a line, vehicles entering a bay) on that footage. This is your ground truth.
  3. Re-encode the same clips at the bitrate and resolution you actually run in production, plus one or two lower settings, and run your detector and tracker on each.
  4. Match each detection or count to the ground truth and compare precision and recall per camera, per setting and day versus night.
  5. Pick the lowest setting where the numbers stop changing, and write down the camera, stream and bitrate next to the result so the next firmware update or recorder change can be checked against it.

Do not compare only totals at step 4. Missed people and double counts cancel each other out, so a total can look right on footage where the individual decisions are poor. Counting each event is more work and it is the only version that tells you anything.

If you ever need footage as evidence, keep the source untouched: UK police guidance asks that video be exported "in the native file format at the same quality as stored on the system", with no further compression on export. The same habit helps analytics, because any re-encoding you do for testing should start from the original, not from a copy of a copy.

The result of all this should be something you can show the people who rely on the numbers. CloudOEngine ships a finalised Vision AI count with a published accuracy report, and every counted crossing is shown, so anyone can see what the cameras actually caught. Our guide to people counting with CCTV covers camera placement for counting in more detail.

How CloudOEngine helps

CloudOEngine is one platform and console for connecting data, including camera streams, alongside pipelines, an AI runtime, Vision AI and live video. Your camera feeds sit next to the rest of your data under one permission model and one audit trail, instead of in a separate system with its own logins.

For counting, Vision AI runs two independent trackers on the same footage. Where they disagree, the case goes to a human review queue where your staff check it. A finalised count ships with a published accuracy report, and every counted crossing is shown, so the count can be audited rather than taken on trust.

When a count turns into an action, such as raising a ticket because a queue is too long, agents can run real tools and every step and tool call is traced and inspectable. With Autopilot, triggered agents follow approval rules: a person approves the action in the app or through an email approve link before it runs.

Governance is included, not upsold: tenant isolation, role-based access, audit logs and per-tenant encrypted secrets, which matters when camera credentials and footage are involved. CloudOEngine is built in Bengaluru, India.

Book a demo or see Vision AI.

Frequently asked questions

Can AI detect people in low-bitrate CCTV footage?

Usually yes, if the people are large enough in the frame. A 2022 study of 50 surveillance videos found detection quality barely changed between about 2.3 and 0.34 megabits per second on average, and dropped clearly only below that, with small, dark and fast-moving targets lost first.

What bitrate does CCTV need for AI object detection?

There is no single number, because the bitrate needed depends on resolution, frame rate, codec, scene detail and how much movement there is. Measure detection on your own footage at two or three bitrates and pick the lowest one where results stop changing.

Should AI analytics use the camera's main stream or substream?

Use the main stream when the targets are small or far away, because substreams are usually much lower resolution and those small targets are the first to disappear. A substream can be enough for a close doorway view where people fill a large part of the frame.

Does super-resolution fix poor CCTV footage for AI?

Only partly. In a study on satellite imagery, super-resolution improved detection most at the sharpest starting resolution and helped much less on coarse images. It cannot recreate detail the encoder threw away, so treat it as an experiment, not a fix.

Why does CCTV footage smear or turn grey in blocks?

That is usually packet loss on the network. Compressed video predicts most frames from earlier ones, so a lost packet corrupts the picture until the next full keyframe arrives. Pulling RTSP streams over TCP instead of UDP often removes it.

Does retraining the model on compressed footage help?

A little. Retraining a detector on compressed surveillance video gave up to a 1% improvement in F1 score on heavily compressed footage in one study, so it is worth doing late, after fixing camera placement and the stream.

Sources

  1. Impact of Video Compression on the Performance of Object Detection Systems for Surveillance Applications (O'Byrne et al., 2022)
  2. Understanding How Image Quality Affects Deep Neural Networks (Dodge and Karam, 2016)
  3. Server-Driven Video Streaming for Deep Learning Inference (Du et al., SIGCOMM 2020)
  4. The Effects of Super-Resolution on Object Detection Performance in Satellite Imagery (Shermeyer and Van Etten, 2019)
  5. Getting to Know Low-light Images with The Exclusively Dark Dataset (Loh and Chan, 2018)
  6. COCO API evaluation code: object area ranges (cocoeval.py)
  7. Police requirements for CCTV systems (UK Government, 2022)
  8. FFmpeg Protocols Documentation: RTSP

#cctv #video compression #object detection #video analytics #computer vision