Math In Motion: Video Compression

Have you ever ever puzzled how it’s potential to place a full-length film which used to suit on dozens of rolls of movie on a reminiscence stick that hangs in your keychain? Really, it’s often potential to place dozens, even a whole bunch of full-length films on a reminiscence stick immediately. That is digital video compression.

Video compression is among the nice successes in extremely mathematical software program outdoors of the analysis laboratory. A real technological breakthrough in video compression in 2003 enabled many video companies akin to Netflix, YouTube, and Skype which are in widespread use immediately.

What’s Video Compression?

Let’s begin with some fundamentals. In computer systems and electronics, a bit is a single piece of data, only a 0 or a 1. A byte is a sequence of eight bits. A single character in a textual content file akin to A or B is often saved as a single byte (eight bits).

A kilobit (kb) is a thousand bits. A kilobyte (KB) is a thousand bytes. A megabit (mb) is one million bits. A megabyte (MB) is one million bytes. A gigabit is a billion bits. A gigabyte (GB) is a billion bytes. A terabit is a trillion (a million million) bits. A terabyte (TB) is a trillion bytes. A petabit is a quadrillion (a million billion) bits. A petabyte (PB) is a quadrillion bytes. Laptop folks ceaselessly use capital B as an abbreviation for byte and decrease case b as an abbreviation for bit.

The scale of recordsdata akin to films on a pc is often expressed by way of bytes, or generally bits. An uncompressed text-only guide (no illustrations) is commonly about one megabyte (MB). A full-length film compressed utilizing trendy video compression applied sciences will take up about six-hundred (600) megabytes on a pc disk drive. A full-length film compressed utilizing the main video compression know-how of the 1990’s (generally known as MPEG-2) takes about 3-4 gigabytes (GB).

The variety of bits of compressed video for every second of video playback is called the bitrate. It is a significantly vital quantity when transmitting or enjoying a video over a pc community. YouTube and different Web movies immediately (2013) typically have a bitrate of 250-300 kilobits per second.

A digitized however uncompressed full size film is often saved as 720 by 480 pixel frames at 24 frames per second. Every pixel is three bytes, one byte for every shade (loosely pink, inexperienced, and blue parts). Colour in video may be very complicated and I’m simplifying the dialogue of shade. An uncompressed ninety minute film is 134 Gigabytes (GB)! The bitrate of uncompressed digital video is about 199 Megabits per second (Mbps).

What does this imply? An old style 1990’s DVD compresses a full-length film by a ratio of about 33.5 (134 GB/ 4GB) to 1! The advances in video compression in 2003 allow one to compress a full-length film by a ratio of about 225 to 1 (and even larger)!

This could be as if — shifting cross nation — you could possibly take all of your possessions weighing 2000 kilos and shrink them right down to lower than ten kilos, put the compressed gadgets in a small suitcase and drive from New York Metropolis to Los Angeles — then reconstitute your possessions in LA.

How Does Video Compression Work?

Beneath the hood, video compression is extraordinarily complicated. The applications (the jargon is video codec — quick for video encoder/decoder) that compress (encode) video and decompress (decode) video are tens of hundreds of strains of laptop code, typically within the C programming language. For instance, the free open-source x264 H.264 video encoder/decoder is over 67,000 strains of code. A line of code is one thing like a single shifting half in a fancy machine like an vehicle or a rocket engine. A contemporary video codec is comparable in complexity to a rocket engine such because the House Shuttle Important Engine which had about 50,000 components.

In video compression, the unique uncompressed digital video is transformed (“encoded” or “compressed”) right into a sequence of digital codes which are saved in reminiscence or transmitted. These codes symbolize the uncompressed digital video however with fewer bits. The video participant or decoder converts (“decodes”) the sequences of digital codes into uncompressed digital video which is then displayed. Video compression fans typically consult with the video compression course of as “encoding” the video and the playback as “decoding”.

Video codecs are tough to implement. Like rocket engines, even a single error is commonly deadly. A single bug in a video codec typically ends in gross seen artifacts within the video that make it unwatchable. Video codecs are sufficiently complicated and interrelated that it might probably take weeks to find and repair a single bug.

A superb programmer might have an error charge of about one bug per one-hundred strains of code. If the programmer implements a 30,000 line video codec, she or he could have 300 bugs. If each bug should be mounted and every bug takes per week, this might be about six years of debugging. Now, truly, bugs don’t all the time take per week to search out and, extra importantly, trendy video codecs are often applied by small groups of programmers.

I gained’t go into the intensive complicated particulars of how video codecs work. I’ll focus on the essential rules utilized by video codecs immediately. Be mindful the true video codecs are rather more complicated than the simplified explanations beneath.

Omit Advantageous Particulars

The human visible system (eyes, optic nerves, and mind) truly can’t even understand many advantageous particulars that video cameras seize and digitize. As well as, there are advantageous particulars that though human can understand them, they don’t care a lot about them and don’t miss them. For instance, people largely understand the sides or boundaries of objects and parts of objects. We don’t typically discover advantageous particulars of the textures of objects akin to pores and skin or clothes.

When you look intently at extremely compressed video on YouTube or elsewhere, you’ll discover that the textures of objects are sometimes smoothed out and lack advantageous particulars. In uncommon instances, they may look blurry. That is the video compression.

In most movies our consideration can be largely targeted on the faces of the folks within the video. Because of this if the face — the eyes, nostril, mouth, hairline, and so forth. — and the pores and skin shade and to a lesser diploma texture of the pores and skin of the face is right, we gained’t even discover issues elsewhere within the video. We frequently pay little consideration to the backgrounds, the main points of the speaker’s clothes and so forth. The farther from the faces, the much less we frequently care.

To make certain, there are exceptions to this, however they’re exceptions.

Video compression applied sciences use mathematical strategies such because the Discrete Cosine Remodel (DCT) to filter out and closely compress these advantageous particulars that people both can’t understand in any respect or pay little consideration to.

Solely Encode Adjustments from Body to Body

A lot of the dramatic success of video compression is because of mathematical strategies, generally known as movement estimation and movement compensation, that encode and transmit solely adjustments between frames.

Contemplate, a easy instance, a “speaking head” video. It is a widespread kind of video during which a speaker in entrance of a static, unchanging background talks with little or no motion. His or her lips transfer, eyes transfer, little or no else. This sort of video is particularly simple to compress. If we encode and transmit solely the adjustments between frames (the background by no means adjustments) we will obtain very excessive compression ranges.

Talking Head Video Frame

Speaking Head Video Body

Fashionable video compression strategies are designed to compress tougher video. Contemplate for instance two folks tossing a ball forwards and backwards between them. They’re standing in entrance of a largely static background. Loosely, we will detect and observe the motion of the ball and ship solely that motion from body to border. That is roughly what movement estimation and movement compensation do.

Use Extra Bits for Uncommon Occurrences

That is identified by the flamboyant and somewhat complicated buzzphrase entropy coding. The fundamental concept is straightforward, use fewer bits (data) to encode widespread occurrences within the video and extra bits (data) to encode uncommon occurrences within the video.

That is truly the way in which languages akin to English largely work. We now have quick one syllable phrases (akin to “he”, “she”, “man”, “canine”, “door” and so forth.) for objects and ideas typically utilized in dialog. English and different languages use longer, multi-syllable phrases for not often encountered objects and ideas akin to “xylophone”. On common, this permits us to speak quicker.

Video compression applications mix superior mathematical variations of those three strategies in very complicated methods to realize the dramatic ranges of compression that most individuals not solely take with no consideration immediately however typically are usually not conscious of in any respect!

Some Historical past of Video Compression

Digital video compression took off within the Far East within the early 1990’s with a know-how generally known as VideoCD that used the unique MPEG-1 digital video compression customary from ISO (the Worldwide Group for Standardization). VideoCD was utilized in Japan, Hong Kong, and different Asian nations for video games, Karaoke, some mainstream films, and particularly pornography.

VideoCD and MPEG-1 had a bitrate of about 1 Megabit per second and achieved a video high quality akin to an previous analog NTSC tv video. That is about as little as one can go in video high quality and obtain widespread use.

VideoCD by no means took off in the US though it had some restricted success with afficionados of porn. The DVD (Digital Versatile Discs) and the MPEG-2 digital video compression that they used did take off and obtain widespread mainstream use in the US and world wide.

DVDs use MPEG-2 digital video with a bitrate of about 4-6 Megabits per second. Some excessive motion video akin to sports activities video or films with heavy motion required larger bit charges. MPEG-2 is similar to MPEG-1 digital video however contains assist for the alternating fields in tv video and another options. The fundamental compression is almost the identical and didn’t considerably outperform MPEG-1. That’s, an MPEG-2 video with a bitrate of 4-6 Megabits per second appears largely the identical as an MPEG-1 video with 4-6 Megabits per second. MPEG-2 was additionally used for distributing cable tv video and another makes use of.

There have been many makes an attempt to realize a lot larger compression ratios/decrease bitrates for a similar perceived video high quality from 1995 to 2003, with negligible success. Increased compression means extra cable TV channels, for instance, and presumably more cash. In all probability, most importantly, if one might push the bitrate beneath the 384 kilobits/second charge of primary Digital Subscriber Line (DSL), it could be potential to distribute movies in real-time over the Web as Netflix, YouTube and different do immediately.

In 2003, video compression leaped ahead in a uncommon technological breakthrough. A lot of enhancements, particularly within the movement compensation and movement estimation, had been mixed efficiently in a brand new model of the H.264 video-conferencing customary (H.264/AVC), then added to the MPEG-4 video compression customary, and quickly added to different video codecs akin to Home windows Media, Adobe Flash, and’s ogg theora. The precise origins of those advances stay a bit murky. There doesn’t appear to be a very good account of the breakthrough and I might be cautious of any account. There are numerous patents and undoubtedly there are lawsuits afoot over who did what when.

In 2003, it turned potential to obtain close to DVD-quality movies over a primary DSL line. A typical new video had a bitrate from as little as 140 Kilobits/second for some speaking heads materials to 350 kilobits per second (beneath the magic 384 Kilobits per second). Netflix, YouTube, and lots of different companies that we take with no consideration immediately turned possible.

Remarkably, once I discuss to most audiences about video compression, most individuals by no means even observed. They simply took the sudden look of top quality real-time video over the Internet with no consideration! It’s somewhat as if Detroit got here out with a automobile that received 200 miles to the gallon, the US pulled out of the Center East, and nobody observed!

The breakthrough video compression in 2003 had some preliminary issues. If one watched intently, there was an occasional jitter between frames which may very well be annoying. Extra significantly, the pores and skin tone was typically off and even considerably pasty. Since our consideration is totally on the faces of audio system and actors, the pores and skin tone was an particularly significant issue, though the video was watchable.

In about 2008, there have been widespread advances in reproducing pores and skin tones extra precisely, in order that immediately it’s uncommon to see a video with a poor pores and skin tone. Each infrequently it occurs, however it’s uncommon. Bitrates didn’t enhance however the perceived high quality did. The jitter that I discussed additionally appears to have largely gone away.

The Future

It could be potential to enhance the compression additional. It’s claimed that the brand new H.265 video compression customary achieves two instances the compression of the present strategies. There seem like numerous teams making an attempt to enhance compression additional.

The present compression ratio may be very excessive (round 225:1 for prime quality video). I did some theoretical calculations at NASA previous to 2003 that indicated it was (simply) potential to realize the compression ranges that at the moment are taken with no consideration. The calculations would additionally point out it might be unattainable or extraordinarily tough to get rather more compression. After all, in follow, theories may be incorrect.

At current, the frontier of video compression lies in attaining dependable, easy-to-use video telephony and conferencing. Regardless of Skype and different video cellphone merchandise, there stays a number of room for enchancment.


Though there was some progress, it stays tough to make a video cellphone name. Many large corporations and organizations have refined video conferencing methods which are typically unused. Some organizations have giant staffs to arrange the video calls and conferences. In follow, the consumer interfaces and the methods are onerous to make use of.

Technical Issues with Actual-Time Video over the Web

The Web was designed over forty years in the past primarily for e-mail and different non-real time textual content transmissions. What this implies is that the Web typically can’t assure {that a} packet (e.g. a body of video or related audio) will arrive in time (say 1/4 of a second for a cellphone dialog). Within the previous days, I might be pleased if an e-mail received to somebody in 24 hours. Even immediately, we not often discover if an e-mail takes a couple of minutes to get to the recipient.

These delays haven’t been a significant issue for video downloading companies akin to Netflix or YouTube as a result of they’ll buffer minutes and even in some instances the complete video. If the Web hangs or slows down for some motive, they’ll often proceed to play from the native buffer till the Web resumes downloading.

In a cellphone dialog, we have to hear and see the opposite celebration inside a fraction of a second of after they truly spoke, made a facial features, gestured, or did one thing else. On this context, it may be tough to make use of video compression successfully. It’s nonetheless widespread to come across audio dropouts, garbling, and a wide range of different issues with Skype and different methods.

Video telephony and conferencing might provide large financial advantages in tremendously lowering journey time and prices, dramatically lowering demand for gasoline and different hydrocarbon merchandise which have develop into more and more costly over the past decade.


For me, probably the most exceptional issues is how unaware most individuals truly are of the video compression know-how that they use and take with no consideration. Most individuals seem to have been utterly unaware of the advances in 2003. Equally, I discover in conversations that most individuals are blissfully unaware of the sophistication and complexity hidden behind a YouTube or Netflix video participant. They typically appear to suppose it’s fairly simple to compress video.

Our huge progress in video compression provides hope that we will efficiently sort out different issues, extra critical issues, by combining the big energy of immediately’s computer systems and electronics with extra superior arithmetic. Certainly, video compression is more likely to help in dealing with our present vitality scarcity (rising costs means a scarcity in standard economics).

So subsequent time that you just watch a Netflix or YouTube video, take a second to mirror that you’re watching a miracle of contemporary know-how!

© 2013 John F. McGowan

In regards to the Creator

John F. McGowan, Ph.D. solves issues utilizing arithmetic and mathematical software program, together with growing video compression and speech recognition applied sciences. He has intensive expertise growing software program in C, C++, Visible Primary, Mathematica, MATLAB, and lots of different programming languages. He’s in all probability greatest identified for his AVI Overview, an Web FAQ (Incessantly Requested Questions) on the Microsoft AVI (Audio Video Interleave) file format. He has labored as a contractor at NASA Ames Analysis Heart concerned within the analysis and improvement of picture and video processing algorithms and know-how. He has printed articles on the origin and evolution of life, the exploration of Mars (anticipating the invention of methane on Mars), and low cost entry to area. He has a Ph.D. in physics from the College of Illinois at Urbana-Champaign and a B.S. in physics from the California Institute of Know-how (Caltech). He may be reached at [email protected].