How do you encode and transcode video or sound files?

What is video compression? How do you encode and transcode video?

In my classes transcoding video and audio is one of the skills that is so easy to learn, but can lead to dramatic improvements in system performance and image quality. I've seen systems go from performing at 2 fps, to 60fps just by re-encoding the video.

As easy as it can be to transcode audio and video, It's very common for students to completely overlook compression and the drastic impact it can have. This is in some ways understandable. Compression has come a long way in the past 20 years, and most everyone today takes it for granted.

In this tutorial I'll show how to encode, decode, and transcode videos from various formats, and discuss what tools are best for doing this.

Before I get into my tutorial, see a few good videos here. First, a quick primer on video compression. Basically there are two types. Spatial compression compresses the image within a frame. Temporal compression compresses images across frames.


This guy on youtube uploaded a video of himself talking. Youtube compressed it. Then he downloaded it and uploaded it again. Youtube re-compressed it. He did this again and again. 1000 times. The effect is that in each pass, the subtle artifacts introduced by the compression are amplified until all you see is pure algorithmic artifact. He is making direct reference here to a sound piece by Alvin Lucier.


Alvin Lucier first did this with sound. He spoke into a microphone, and played that back from speakers in a room. He recorded that, and played the second generation back through the room speakers. Again and again, until all you hear is the artifacts introduced by the room itself.