How To Post Video on the Net; Part 2: Compression

25 03 2008

In part one we took a look at the first step to post decent quality video to sites such as YouTube, by using a filter to ‘de-interlace’ the footage in order to make the video itself web ready. Today we are going to look at compressing that file to make it small enough to be accepted, and still big enough so that it doesn’t look ugly.

To do that, we will start by figuring out how compression works and then some basic tips and tricks to making compression work for you, instead of against you.

What is compression?

Compression is just what it sounds like. It is taking something large and squeezing it down to make it smaller. When it comes to all things on your computer, compression is a standard way for the computer to take what could be a huge file and make it manageable.

How does compression work?

Compression isn’t a new thing, in fact it has been around since the early days of computing, in forms you might recognize such as ‘winzip’. Understanding how basic computer compression works is pretty easy.

Imagine for a second that data on your computer is like a string of yarn. If you took all the yarn you needed to knit a sweater and laid it all out on the ground it would probably fill the floors of your house. So you perform a type of compression, you ball it all up. You do it in a nice neat way because if you just grabbed it all and stuffed it in a bag it would get all tangled. So instead you slowly ravel it in to a ball so you can get to it as you need it. We do the same thing with data, we roll it in to a neat ball on the hard drive so that it doesn’t get tangled up. The computer does it in such a way that the data flows smoothly, because if we hit to much data at once (like a knot in the yarn) the computer slows down do unravel it all and we get loading or freezing on our computer.

Back to the ball of yarn. If you took that ball and squeezed all the air out of it it would get smaller. You would have ‘compressed it’ If you could keep it that way you could store a lot more balls in a much smaller drawer. This is exactly how digital compression works. It takes all the extra spaces and repeated bits out of a file and replaces it with smaller bits of code so that it can be stored in a smaller space. To do this it uses something called a ‘codec’

Ok, I get it, now what the heck is a codec?

Unlike the ball of yarn you can’t just take all the air out of a bunch of data. It would get messy and unreadable pretty quick. You CAN take out some erroneous and repeated data and replace it with smaller bits. Imagine every space in this paragraph actually takes about 10 bits in the data world. To us it is a space but to a computer it is 001011001. (i made that up.. don’t quote me) If we could replace this data with one simple mark like lets say ‘-’ it would take up less space. The problem is that you need to be able to ‘de-code’ that new mark and tell the computer “Whenever I say ‘-’ I really mean 001011001…ok?” That’s what a codec does. It ‘encrypts’ the extra data, and then uses a special ‘de-coder ring’ do decrypt it in the original larger format so the computer can read it.

So what does that have to do with video?

Digital compression really hit its stride when it left the world of compressing boring old computer files and started dealing with things like music. Back in the 80’s someone had the wild idea that we could take the same idea and apply it to sound. Instead of giving the computer every tiny bit of sound data and getting the computer to reproduce that sound, we could simply use a codec. Boom… we are able to store that data on small disks.. and the CD is born. Eventually we got much better codecs, and now we can store hundreds of songs on a cd using .mp3… all .mp3 is.. is a better codec that is better at compressing the audio data.

However, video was a conundrum. Video is much harder than audio in the grand scheme of things. With video you need to have color information for every pixel on the screen… how do you compress that without seriously altering the image? At first even short videos took up huge chunks of space on hard drives, it seemed like it would never really work.

It must have taken a dreamer to come up with the solution, because the solution lay in the sky. When you film the sky it stays a nice even blue, and if you have a steady hand, it will stay on the screen for a long time, in the same place. AHAA!!
What if instead of saying to the pixel ‘i need the color blue’ 30 times every second, we said ‘i need the color blue here for the next 800 frames’? If we could do that we could save a lot of space! Bammo! Video codec was born. The first place consumers really saw codecs at work was on DVD’s. DVD’s use an older codec called MPEG-2. Since then the codecs keep getting better, and now we have codecs that can do HD video on the same size of disk.

It took a long time to get right, and has really only become a viable technology in the last 10 or so years. But when we did get it right it revolutionized everything! When video and computers learned to play together nicely it opened up a new age of digital video and effects work, and suddenly directors could make movies like ‘300′ and ‘Titanic’… but thats another story.

Ok…so what does it all mean to me?

Understand codecs and you understand how to get good quality video on the web. Codecs are always improving and are not created equal. Old codecs do substandard jobs and eventually become defunct. Some codecs improve constantly but not all computers will have access to them. You need to strike a balance between quality and availability. Find a codec that does a good job but that everyone can see on their screen. The problem is that there are a lot of codecs out there.

Apple owns and supports a program called ‘Quicktime’ that has been around a long time. Quicktime is a piece of software that can read and compress using several codecs. It is the standard in the video industry. You can spot a quicktime file when it has the tag ‘.mov’ at the end of it such as ‘mymovie.mov’. Microsoft has their own program ‘.wmv’ and flash has one too… ‘.flv’ (often called a ‘flash video file) The secret behind why these programs survive while others die is actually because they are a combination of codecs all contained within a singe reader. A ‘quicktime’ player can read 20 or so codecs that all have that same ‘.mov’ tag. Whenever a new codec is developed by the folks at apple (or they buy someone else’s work) they add it to their codec ‘reader’. Think of it like a family. Different people, but all with the same last name. The actual ‘codec’ it is using could be called something like ‘h.264′or ‘mpeg2′, but to make it easy for the consumer they lumped it in to ‘.mov’ so that you only need to download one piece of software to read it.

I get it, geeze, get on to explaining how it works!

So you made your video of your ‘gnarly whitewater run’ and you want to post it for the world to see. You de-interlaced it because some goober on the internet told you to, and now you are ready to kick it out of your editing software and post it. So you click on ‘export’ and you give it a name and there it is on your desktop.. but holy crap!!! the file is 5 gigs! You take a deep breath and wade in to the ‘advanced settings’ tab of your video editing software and you are confronted with all kinds of options… you click on ‘video for web’ and it exports to your desktop.. phew! the file is only 10 kilobytes! You click on it to watch it and… what the hell??? The video is the size of a thumb and so blurry you can’t see your gnarly whitewater run any more!!

Don’t panic. You understand the basics of compression and can now start to make compression work for you!

Step 1: Before you do anything you need to find out what formats are supported by the site you plan to use. YouTube currently supports WMV, .AVI, .MOV, and .MPG formats.

Step 2: Find out what the biggest file possible is. In the case of you tube that is currently 1024 mb and can be a maximum of 10 minutes in length.

Step 3: Leave the relative comfort of presets and venture in to the world of advanced compression!

I’m ready! … wait a second … what the hell are all these settings… help!!!

I am going to assume you are using Final Cut. (Sorry folks with premier, Don’t worry, a lot of this stuff will work the same fundamental way)

If you are using a basic editing program such as iMovie or windows movie maker, you won’t have as many options. The solution is to export it in all the different formats that the program will allow. Take a look at the size of the file, watch the movie and see how the quality is, and upload the one that has the right codec type, the best quality and is under your ‘file size limit’. (delete the ones you aren’t using because you can fill up a hard drive quickly)

If you are using Final Cut or a similar program it is time to open up the advanced settings for exporting your file. In the case of Final Cut.. it’s time to open up (duhn duhn duhn) “Compressor”. (File>Export>Export using Compressor)

preview the result

The advantage to compressor is that you can preview the size of the file you are going to get after you export. This is super handy as it will let you play with the settings until you can get under the ‘maximum file size’ limit, while allowing you to play with the frame size and quality of your video. It even allows you to preview what the video will look like after compression, so you don’t get a nasty surprise after you have let it work at a file for 5 hours.

How do I make the file smaller?

There are a few different settings you can play with that will quickly make the file size smaller.

  1. Frame size- If the video takes up less space on the screen, the file will have to deal with less pixels.. less pixels, smaller file size
  2. Quality- This is sort of a ‘catch all’ setting. The lower the quality of the image, the more compression you are allowing the codec to do. Heavy compression will give you smaller files, but you may not be as impressed with the result
  3. Bit Rate- We’ll talk about this more in a second, but lower the bit rate and you lower the file size.. and also,again, the quality.
  4. Codec- some codecs will produce smaller files. In this case I generally recommend sticking with .mov and using the h.264 codec, unless your posting site doesn’t support .mov files.. which is pretty unlikely, but does happen.
picture-4.png
The bad news is that I can’t really just give you a simple solution here.

I can’t say.. just hit these three buttons and you will get perfect quality video ready for the web. You need to play with these settings, get to know them and alter them depending on the video. Slowly striking a balance between file size and image quality. I can tell you that the ‘web streaming’ options give you decent quality video, makes sure that the video doesn’t stutter too much and will resize it nicely.

To see how the video is affected by your choices, click on the ’summary’ option in the inspector while you have the setting highlighted in the ‘Batch’ window. You can see that is shows the ‘estimated file size.’ Now all you have to do is play with the settings until you can get the file size small enough, while still being comfortable with the quality of the image!

The real key to playing with compression is playing with the ‘data rate’. Remember our ball of yarn? The data rate is the rate that the yarn is fed to the net. (or in this case..data) Imagine the internet is a series of tubes.. oh crap.. I can’t believe I just said that… I mean…

Imagine the amount of data that you can get from the internet at any one time is like a pipeline to your computer. The pipe has a diameter and can only feed so much data to the computer at any one time. Let’s say your computer has a data rate of 1000 kilobytes per second. If we try to feed more than that at any one time the pipe gets clogged up for a bit… and the video will freeze up as the computer tries to sort out the data and get the next chunk it needs. If we make sure that the video never exceeds this 1000kb/second, the video will always play smoothly! Your compressor is capable of making sure that the video is compressed enough to always do that!

The second advantage is that if you play with the data rate it will severely increase or decrease the size of the file after compression! The lower the data rate.. the smaller the file. As always, this will be at the cost of image quality. The higher the data rate.. the higher the quality of your video!

Anyway, thats it for this week. I think I have left you with more than enough to work on. I hope to have time to fiddle a bit with ‘Premier’ and be able to add a part two to this post for those of you without Final cut. All in all I am sure many of the concepts are the same and it will be up to you to fiddle with the settings.

Good Luck!

Next week we will discuss frame size in more detail, a brief word on pixelation and finally, look at how to add letter boxing to your video!

Until then, feedback is always appreciated. If anyone out there is a Premier guru and can give some options for web video, pass it on!

The Animal


Actions

Informations

3 responses to “How To Post Video on the Net; Part 2: Compression”

25 03 2008
25 03 2008
Alex G. Raccuglia (23:00:46) :

There is something really unexact in your article:
QuickTime IS NOT a codec, it’s an ARCHITECTURE.
You can use severa different codecs (audio and video) INSIDE an ARCHITECTURE.
EG: QuickTime format for a file and two codecs: H.264 or Sorenson for video and AAC or IMA for audio…

26 03 2008
videoanimal (12:20:47) :

You are absolutely right! I was trying to avoid getting in to the concept of architecture vs codec but I spose it just muddies the issue. I will do what i can to clarify.

The Animal

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>