Vision Detection Systems
TECHNOLOGY LIBRARY

Video Compression for Security Cameras: H.264 and H.265 Explained

H.264 and H.265 are video compression standards that make surveillance video small enough to store and send. They save space by sending only what changes between frames and by predicting each block of an image from nearby data. H.265 generally reaches similar quality at a lower bitrate than H.264, but needs more processing power to encode and decode.

Why do security cameras compress video?

Raw video is enormous. The data rate is roughly the width times the height times the bits per pixel times the frames per second, and for a high resolution camera that quickly reaches amounts no ordinary network or disk can carry around the clock. Compression exploits the fact that video is highly redundant. Neighboring pixels are similar, and from one frame to the next most of the scene does not change, especially for a fixed camera watching a quiet yard.

A codec, short for coder-decoder, is the pair of algorithms that squeezes video at the camera and rebuilds it at the viewer. Compression is lossy: some detail is discarded permanently, chosen so people notice it least. That is a trade-off for security, because the detail that gets discarded can be exactly what you wanted, such as fine texture on a face or characters on a plate. Compression settings are therefore a quality decision, not just a storage one.

How do H.264 and H.265 work?

Both standards split each frame into blocks and encode them in three ways. An I-frame, or key frame, is encoded on its own like a still image. A P-frame stores only differences from an earlier frame, using motion vectors that say a block moved to a new position. A B-frame can refer to both earlier and later frames. The run from one key frame to the next is a group of pictures, and its length affects both file size and how quickly a viewer can jump to a point in the video.

After prediction, the encoder transforms the leftover differences into frequency components, discards the least visible ones through quantization, and packs the result with entropy coding, which gives shorter codes to common patterns. Quantization is the lossy step and is controlled by a quality parameter. Because a still camera sees a mostly unchanging background, most frames are small, and the data rate rises when something moves, the lighting changes or the image is noisy.

What is different about H.265?

H.265, also called HEVC, builds on the same ideas with more flexible tools. Instead of fixed small blocks, it uses larger and variable coding units, offers more directions for predicting a block from its neighbors, and has better filtering to reduce block edges. The net effect is that it can usually hold similar visual quality at a lower bitrate than H.264, which is especially helpful for high resolution cameras and for limited links.

The cost is computation and compatibility. Encoding and decoding H.265 takes more processing, so older viewing devices, browsers and recorders may struggle or lack support. Licensing and patent arrangements also differ from H.264. Many cameras add proprietary smart modes on top, which lower bitrate further by treating a static background differently; these can complicate playback in other systems. When you compare cameras, check which codec profiles the camera streams and which ones your video platform can decode.

Bitrate control: constant, variable and capped

Bitrate is how much data per second the video uses, and encoders manage it in different ways. Constant bitrate holds the rate steady, which keeps network use predictable but lets quality drop when the scene gets busy. Variable bitrate holds quality steady and lets the rate swing, which saves space in quiet scenes but can spike. Capped variable bitrate is a compromise: quality is the goal, but a ceiling prevents the spikes from overwhelming a link.

Scene content matters as much as settings. Night footage with sensor noise, rain, snow, swaying trees and moving shadows all cost bits, because the encoder tries to preserve every change. Higher frame rate and resolution also raise the rate. Reducing noise at the source, with good lighting and sensible gain, often lowers bitrate more than tweaking the codec. Choose frame rate for the task: smooth motion matters for a PTZ following a target, and less so for a static gate view.

Storage need is a simple formula: bitrate multiplied by recording time, divided by eight to convert bits to bytes, then multiplied by the number of cameras. Halving the bitrate roughly halves the disk needed, which is why codec choice shows up directly in retention length. The same arithmetic applies to bandwidth: continuous streaming of every camera to the cloud may need an uplink far larger than a cellular connection comfortably offers.

Common solutions are to record locally at full quality on the device and send only what is needed over the network. Many cameras produce two streams: a main stream for recording and a smaller sub stream for live viewing or analytics. Event-based uploads, lower frame rates on remote views and efficient codecs all reduce the load. If you plan to rely on cellular, ask how much video is actually sent and whether the full quality copy is kept at the site.

Compatibility and settings that matter in practice

Before settling on a codec, test the whole chain: the camera, the recorder or video platform, and the devices people will use to watch. Hardware decoding on phones and computers makes H.265 smooth; without it a screen with many streams may stutter. Key frame interval is another detail: a very long group of pictures saves space, but makes searching slow and means a damaged frame can affect more of the video that follows.

For evidence, avoid pushing compression so far that faces and plates lose detail. A little extra bitrate on the camera that watches the entrance is cheaper than losing the one frame you needed. Keep a consistent configuration across cameras where possible, and use open standards such as ONVIF profiles and RTSP streams so you can change platforms without replacing cameras. Document your chosen settings so technicians do not reset them by accident.

Key terms

Codec
A coder-decoder: the algorithm pair that compresses video at the camera and reconstructs it for viewing or playback.
I-frame
A key frame encoded on its own, like a still image, which serves as a starting point for the frames that follow.
P-frame and B-frame
Frames that store only differences from other frames, using motion vectors, so they are much smaller than key frames.
Group of pictures
The run of frames from one key frame to the next, whose length affects file size and how fast you can seek.
Bitrate
The amount of data used per second of video, which drives both storage needs and network load.
Quantization
The lossy step in which the encoder discards the least visible detail, controlled by a quality setting.
Sub stream
A second, smaller video stream from the same camera, used for live viewing or analytics while the main stream records.
IN THE FIELD

Compression is what makes cellular connectivity practical on a trailer. The cameras support ONVIF and RTSP, the unit records on site through edge recording, and two weeks of cloud recording is a standard value-add, so efficient streams stretch both storage and the uplink. The dual-SIM 4G/5G router plus eSIM carries the traffic, with unlimited data and no overages, and sensible stream settings still keep live viewing and alert verification responsive.

Common questions

Is H.265 always better than H.264?

Not always. H.265 usually needs less bitrate for similar quality, but it takes more processing and may not play smoothly on older devices or software. If everything in your chain supports it, it is often a good choice, so test first.

Does more compression hurt evidence quality?

It can. Compression discards detail, and heavy settings may blur faces, plates or small objects, especially at night. Use enough bitrate on cameras that cover entrances and key areas, and review sample footage before you rely on it as evidence.

How do I estimate storage for security cameras?

Multiply each camera's bitrate by the recording time in seconds, divide by eight to get bytes, and add the cameras together. Actual rates vary with scene activity, so check real bitrates after the cameras have run in your conditions.

SITE SECURITY DESIGNER

See it on your site.

Type your address, and the designer opens on a live map of your property — place trailers, draw the perimeter, and get a coverage plan in minutes. No call required.

FREE · NO ACCOUNT · SATELLITE VIEW OF YOUR ACTUAL SITE