Introduction to Video Codecs: JPEG, MPEG4, and H.264
Overview
Most, if not all, IP cameras stream video compressed. The method used to compress video are called 'codecs'. There are 3 common codecs widely used today; JPEG, MPEG4, and H.264. Most cameras support more than one codec as each codec has its pros and cons. There's no single 'best codec' in the world.
JPEG
Pros
- Best (static) image quality
- Easy to decompress (low CPU loading)
- Best compatibility
Cons
- Low compression rate (high data rate)
- Low frame rate
JPEG is widely used in consumer products and had been developed earlier. It's less prone to broken images and has the best image quality. The problem with JPEG is that it's originally designed for static images. The frame rate is usually low and data rate is high. Motion JPEG, MJPEG, and MJPG all refer to the same thing; they are basically a series of JPEG images.
H.264
Pros
- Best compression rate
Cons
- Compress/decompress complexity (heavy CPU loading for both camera and NVR)
- Compatibility issue
H.264 is a more advanced technology for compressing video. It analyzes foreground (changing parts) and background (static parts) in video and avoid redundant information. The compression rate is significantly higher than JPEG. But this method causes few problems that haunt IP surveillance for years:
- Inconsistent image quality - When a snapshot is taken it could be almost as good as JPEG or it could be very low quality.
- Artifacts - Artifacts (image features created by compression and are not visible in real scenes) appear in all compressed video, both JPEG and H.264. But in in JPEG they are more consistent and in H.264 the artifacts usually grow and disappear suddenly and grow repeatedly. This makes motion detection and object tracking very unstable.
- Computing complexity - It takes considerably higher CPU time to decompress H.264. To display multiple live H.264 videos, NVR systems must use very high-end and expensive PCs.
- Compatibility - H.264 is sophisticated and 'sophisticated' usually means complicated. Different venders and parties do not always understand H.264 standard the same. This sometimes leads to problems causing corrupted images or even data that cannot be decompressed at all.
The two images are 2 consecutive frames of an H.264 video. The right image shows artifacts which are absent in left one.
MPEG4
Pros
- Easy to decompress (compare to H.264)
- Good compatibility (between JPEG and H.264)
Cons
- Mediocre quality and compression rate (between JPEG and H.264)
MPEG4 generally works the same way as H.264 and has the same pros and cons. The compression rate, image quality, complexity and compatibility are all between JPEG and H.264.
Applications
Most IP cameras today support multi-stream. A common setup is JPEG for live and H.264 for recording. Or you can use a low-resolution, high frame-rate JPEG for live and a high-resolution, low frame-rate JPEG for playback. But even low frame-rate JPEG still requires much more storage than H.264.
JPEG |
H.264 / MPEG4 |
|
Live view, for performance |
Good |
Poor |
Live view, for smooth |
Poor |
Good |
Recording, for extended time |
Poor |
Good |
Recording, for evidence |
Good |
Poor |
Motion detection Object tracking Facial recognition LPR |
Good |
Poor |
Limited network bandwidth |
Poor |
Good |
Genius Vision NVR is bundled with a calculator that helps users to decide how much storage is required.
See also