Introduction to Video CODECs : MJPEG, MPEG-4, H.264

By: John Honovich, Published on Jun 13, 2008

CODECs are a critical element of choosing, designing and using video surveillance systems. CODECs can lower the price of overall systems and increase the usability of systems. As such, having a basic understanding of what a CODEC is and why CODECs are used is important.

Fundamental Principle of CODECs

The most important factor to understand in video CODECs is that CODECs help balance off different costs.

For instance, let's say you want to go to the mall and to the supermarket. A few years ago, when gas was cheaper, you might have done this in 2 separate trips. Now that gas prices have increased dramatically, you might want to combine those trips. What's happening here is that as gas has become more expensive, you are willing to trade off lower convenience for savings in cash.

Likewise, using CODECs is a balance between the cost of storage, bandwidth and CPUs. Specifically:

CODECs reduce the amount of bandwidth and storage needed at the expense of using more CPU cycles.

As such, selecting a CODEC always requires you to understand the tradeoffs in cost between using less bandwidth and storage or using less CPU cycles. Generally CPU cycles are cheaper than bandwidth and storage so more advance CODECs save you money. Sometimes, CODECs can be too demanding, especially with megapixel cameras and can potentially cost you more in CPU than you save in bandwidth and storage.

Please read our basic bandwidth tutorial for a review of it's impact on video surveillance.

CODECs Overview

Video must be digitized for it to be used and viewed on a computer. CODECs are means or choices in how we make the video digital.

CODECs or compression / decompression technologies are used to modify the video that is being digitized. Similar to how you might ZIP files on your PC, the video is compressed on its way into the computer. And just like with opening a ZIP file, the video is decompressed before you use or view the video. Unlike ZIP files, the compression of video losses some of the information (engineers refer to this as lossy compression). However, with the appropriate settings, a user cannot tell the difference visually.

Get Notified of Video Surveillance Breaking News
Get Notified of Video Surveillance Breaking News

Just like in the movies or TV, video is a series of images that are displayed rapidly one after the other. In the US, TV consists of displaying a series of 30 images per second. When we view these 30 images per second, it's “video” and it looks smooth. The fact that video is made up of a stream of images is quite important for understanding CODECs.

When you use a CODEC, you can compress the video in two fundamental ways:

  • Compress the individual image by itself
  • Compress a series of images together

When you compress an individual image by itself, you simply take the image, run the compression and output the saved file (technically called intraframe compression). Just like when you use Microsoft Paint and save as a JPEG, video compression of individual images works quite similarly. The difference with video is that you need to do these for a continuous stream of images. As such, rather than simply being a JPEG, it is called Motion JPEG or MJPEG.

The benefit of MJPEG is that it requires very low CPU use. The downside is that storage and bandwidth use can be quite high.

When you only compress an individual image, you ignore what's going on between multiple images in a sequence and often send redundant information. If you are streaming video at multiple frames per second, you often are sending basically the same image over and over again. This can be quite wasteful. It's similar to someone calling you up every minute to tell you nothing changed. It would be far better for the person to only call you when news occurred. You can simply assume during the rest of the time that the status is the same.

When people talk about the benefits of MPEG-4 and H.264, not sending repetitive information is the core source of their strength. Evey so often these CODECs will send a whole image (often called an i frame). The rest of the times they only send updates describing what parts of the image have changed (technically called interframe compression). Since it is common that large parts of the image remains the same, this can result in very significant reductions in storage and bandwidth. For example, where MJPEG may send image after image at 100 KB, codecs like MPEG-4 or H.264 may send the first image at 100 KB but the next 3 or 4 images at only 10 KB each. This can approach can reduce bandwidth and storage use by 50 – 90%.

The downside with this approach is that it takes more work for the computer to do this. When you are simply compressing individual images, you do not need to worry about what happened before or what the next image will contain. You simply apply the compression rule and execute. With MPEG-4 or H.264 you need to examine groups of images and make complex calculations of what changed and what did not. You can imagine this can become very complicated and consume lots of CPU resources.

H.264 and MPEG-4 are similar in that they both reduce bandwidth and storage by examining groups of images when they compress video. A key difference with H.264 is that it uses much more complex and sophisticated rules to do the compression. Because H.264's rules are more sophisticated, they can reduce bandwidth and storage even more than MPEG-4. However, the trade-off is that it takes more CPU cycles to do it.

Looking at Current Video Surveillance Systems

The general trend in video surveillance has been a continuous movement to CODECs that save bandwidth and storage. Historically, you have seen products move from MJPEG to MPEG-4 to H.264. The reason why this has happened is because the cost of CPUs to compress the video has decreased faster than the cost of bandwidth and storage. Most experts expect this trend to continue.

Recently, the biggest challenge using CODECs in video surveillance systems has occurred with the rise in megapixel cameras. For years, the maximum resolution of security cameras was constant.However, with megapixel cameras, the resolution of security cameras has increased by 400% or more. The greater the resolution, the harder the CPU needs to work and the more cycles that need to be allocated.

The huge increase in resolution is similar to the jump in gas prices. It has changed the economics of CODECs. Whereas historically, for standard definition security cameras, CPU cycles were cheaper than bandwidth and storage. Now, since so much more CPU cycles are needed, it can cost way more in CPU than what you save in bandwidth and storage. As such, most commercial megapixel cameras use MJPEG, especially if they are multi-megapixel (more than 1.3 MP).

One of the most important elements in the next few years will be the development of new approaches and use of new CPUs to reduce the cost of using H.264 for megapixel cameras. Much like alternative energy development hopes to bring the cost of energy down, new approaches are being sought to reduce the use of CPU cycles in compressing megapixel camera feeds.

Conclusion

Related Reports

$800 Axis Thermal Camera Examined on Jan 02, 2018
Axis is releasing two of the lowest cost thermal IP cameras ever. But will low cost be enough to spur adoption? In this note, we examine the 2 new...
Directory of 30+ VSaaS / Cloud Video Surveillance Providers on Jun 07, 2019
This directory provides a list of VSaaS / cloud video surveillance providers to help you see and research what options are available. 2019...
Anixter - Falling Video Prices on Jul 26, 2017
Falling video prices are such a concern that it has become a notable topic for Anixter's financial results and Anixter's executives. In this...
Multicasting Surveillance Tutorial on Jan 04, 2018
Network bandwidth can be a concern for some surveillance systems. While improvements in video codecs, such as smart codecs for H.264 and H.265,...
VMS Server Sizing on May 25, 2018
Specifying the right sized PC/server for VMS software is one of the most important yet difficult decisions in IP video surveillance. In the past...
STP vs UTP for Video Surveillance Tutorial on Dec 20, 2017
For many video system designers, deciding which ethernet cabling to use is a quick decision: go with the cheapest. However, this overlooks the...
Axis Tailgate Detection Tested on Jan 04, 2019
Axis is aiming to tackle tailgating, one of access control's biggest issues, with the Tailgating Detector ACAP application. This camera app claims...
Cutting Costs 70% Using Milestone With HD Analog on Feb 23, 2017
HD analog and enterprise VMSes are often thought of as being on opposite sides of the spectrum, with HD analog best for small jobs due to its low...
Smart Codec Guide on Feb 01, 2018
"Smart Codec" was once seemingly a marketing buzzword, but in 2020, nearly all new camera models include this tehcnology. These marketing names...
Camera Calculator V3.1 Release Improves User Experience on Oct 17, 2019
IPVM has released a new version of our Camera Calculator, V3.1, with significant user experience improvements, a new development plan, and an...

Most Recent Industry Reports

Sperry West / Alibaba Tablet Temperature Measurement Tested on Jul 07, 2020
In April, we ordered a ~$500 temperature tablet from Alibaba. We set it to the side while doing 18 other temperature screening tests but, after...
Video Surveillance 101 Book Released on Jul 07, 2020
IPVM's unique introduction to video surveillance series is now available as a 145-page eBook. Designed for managers, salespeople, and engineers new...
Startup Duranc Presents AI VSaaS on Jul 06, 2020
Duranc presented its system at the May 2020 IPVM Startups show. A 30-minute video from Duranc including IPVM Q&A Background on the...
Low Voltage Nation Wants to "Help You Carve Out A Fulfilling Career" Interviewed on Jul 06, 2020
It is difficult to make your way in this industry as there is little formal schooling. However, one person, Blake Urmos, the Founder of Low Voltage...
The Next Hot Fever Detection Trend - $100 Wall-Mounted Units on Jul 06, 2020
The first wave of the booming fever detecting market was $10,000+ cameras, now interest for ~$2,000 tablets is high and the next big thing may be...
Cisco Meraki Unlocks IP Cameras With RTSP Tested on Jul 06, 2020
Meraki opened up its cameras to 3rd party NVRs/VMSes by offering RTSP streaming because of "the need to solve a business problem". We tested...
Hikvision Illicitly Uses Back To The Future In Marketing on Jul 03, 2020
NBCUniversal told IPVM that Hikvision UK's ongoing coronavirus marketing campaign using NBCUniversal's assets was not allowed. Hikvision mass...
Verkada: "IPVM Should Never Be Your Source of News" on Jul 02, 2020
Verkada was unhappy with IPVM's recent coverage declaring that reading IPVM is 'not a good look' and that 'IPVM should never be your source of...
Vintra Presents FulcrumAI on Jul 02, 2020
Vintra presented its FulcrumAI object recognition and mask detection offering at the May 2020 IPVM Startups show. Inside this report: A...