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

Author: 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 Video Surveillance News In Your Inbox
Get Video Surveillance News In Your Inbox

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

Understanding the basic choices in CODECs and rationale for choosing CODECs is a key element in video surveillance systems. Please share your questions or feedback below.

Related Reports

Save $50 - IP Networking Course September 2017 on Aug 16, 2017
Tomorrow, Thursday, August 17th is the last day to save $50 on the September IP Networking Course. This is the only networking course designed...
Cat 5e vs Cat 6 vs Cat 6a Network Cable Usage Statistics on Aug 16, 2017
Cat 5e? Cat 6? Cat 6a? What do integrators use in practice, today? 140+ integrators told IPVM. Here are the results: For those who want to...
IP Camera Specification / RFP Guide 2017 on Aug 14, 2017
RFPs are hard. Do them 'right' and it takes a lot of knowledge and time. Do them 'wrong' and you can be (a) unwittingly locked into a specific...
IR Surveillance Guide on Jul 31, 2017
Infrared (IR) has become an increasing core component to video surveillance systems. In particular, the expansion of integrated IR cameras that...
Nest Cam IQ Tested on Jul 10, 2017
Nest has released their latest entry in their camera line, the Nest Cam IQ, touting 4K "Supersight", facial recognition, "HD audio", invisible IR,...
H.265 / HEVC Codec Tutorial 2017 on Jun 30, 2017
For years, video surveillance professionals have talked about the potential for H.265. Now, in 2017, H.265 is starting to gain mainstream...
Hikvision H.265+ Tested on Jun 27, 2017
Hikvision, which in the past few years released H.264+ (see test results) has now released H.265+, that claims even greater bandwidth savings. We...
Covert Cloud Camera Service Launching (KJB) on Jun 22, 2017
Cloud IP cameras, for consumers, has become increasingly commonplace. However, covert cameras, lag there, with few options. Now, North America's...
45 Drives 'Lowest Cost' Enterprise Storage Company Profile on Jun 21, 2017
45 Drives claims the "lowest cost per Hard Drive Slot in the industry." But who or what is '45 Drives'? What started as a product design to...
Axis 20MP Q1659 Camera Tested on Jun 13, 2017
Axis has joined the super high resolution camera trend with their Q1659, a 20MP model equipped with Canon's APS-C sensor. We tested the Q1659...

Most Recent Industry Reports

Save $50 - IP Networking Course September 2017 on Aug 16, 2017
Tomorrow, Thursday, August 17th is the last day to save $50 on the September IP Networking Course. This is the only networking course designed...
Hikvision Responds To Cracked Security Codes on Aug 15, 2017
Hikvision has responded to IPVM's report on Hikvision's security code being cracked, both with a 2 page update to dealers and communication...
Stolen Video NVR / DVR Statistics on Aug 15, 2017
"But what happens if someone steals my recorder?" Anyone who has done more than a handful of jobs has probably heard this question several times....
Hikvision Europe Cutting Out Unauthorized End User Sales on Aug 15, 2017
The days of anyone buying Hikvision from anywhere off the Internet are numbered, at least in Europe, if Hikvision's plan comes to fruition. In...
Axis Laser Focus PTZ Tested on Aug 14, 2017
Axis has been touting its new Q6155-E laser focus PTZ as 'always in focus' and 'always in color'. Does it really deliver? We bought and tested...
Vulnerability Directory For Access Control Cards on Aug 14, 2017
Knowing which access credentials are insecure can be unclear, especially because most look and feel the same. Even the most insecure 125 kHz types...
IP Camera Specification / RFP Guide 2017 on Aug 14, 2017
RFPs are hard. Do them 'right' and it takes a lot of knowledge and time. Do them 'wrong' and you can be (a) unwittingly locked into a specific...
Cellphone Usage Issues For Integrators (Statistics) on Aug 11, 2017
Cellphones clearly offer significant advantages in communication and problem solving. But they can also be a major pain point if employees...
Rebooting IP Camera Statistics And Practices on Aug 10, 2017
Dahua cameras automatically reboot weekly, by default. Is this an innovation by the Chinese mega-manufacturer or a sign of a problems? 125...
Avigilon Profits Surge, Stock Jumps (Q2 2017) on Aug 10, 2017
Avigilon said earlier this year they would shift their strategy to maximizing profits. Now, they are delivering it and the stock market is...

The world's leading video surveillance information source, IPVM provides the best reporting, testing and training for 10,000+ members globally. Dedicated to independent and objective information, we uniquely refuse any and all advertisements, sponsorship and consulting from manufacturers.

About | FAQ | Contact