A codec is a method for encoding or decoding data--specifically, compressed data. Though the word codec has become somewhat generic, the term was originally a shortened form of compressor-decompressor. That's what codecs do: they take digital media data and either compress them (for transport and storage) or decompress them (for viewing or transcoding.)
Raw video and audio data consume vast amounts of storage space. Uncompressed 1080i high-definition video recorded at 60 frames per second eats up 410 gigabytes per hour of video. CD audio, which is pretty passé by modern standards, puts about 74 minutes of audio on a 680MB CD. However, eight channels of audio encoded at 24-bit resolution churns through 16 megabits per second, or a little over 7 gigabytes per hour of audio. Even with high-speed broadband, that's too much data. That's why video and audio needs to be compressed for storage.
Once the media data is compressed into suitable formats and reasonable sizes, it needs to be packaged, transported, and presented. That's the purpose of container formats--to be discrete "black boxes" for holding a variety of media formats. Good container formats can handle files compressed with a variety of different codecs.
Dozens of codecs exist, with specific use models; most of them you may never encounter as a typical consumer. This section focuses on codecs as compression/decompression schemes, not as specific software that may encode or transcode video. That discussion comes later.
Disc-Based Delivery Formats
Let's talk about the old-fashioned DVD or slightly more newfangled Blu-ray Discs for a bit. Despite the increasing popularity of streaming video, the capability to deliver disc-based media is still needed. I've created Blu-ray and DVD discs to hand out to parents of high school athletes, or to send to relatives, for example. Practically everyone has a DVD player, and you don't need an Internet connection to share a DVD.
Streaming From the Web
Delivering video over the Web necessarily means compromises, mostly trading off image quality for lower bit rates. Broadband bit rates vary depending on the ISP and transport technology. Most of what applies to Web content delivery also applies to video stored on mobile, handheld devices.
The Right Container: Flexible and Usable
Containers for Archiving and Capturing
QuickTime: QuickTime is Apple's own container format. QuickTime sometimes gets criticized because codec support (both audio and video) is limited to whatever Apple supports. This is true, but QuickTime supports a large array of codecs for audio and video. Apple is a strong proponent of H.264, so QuickTime files can contain H.264-encoded video.
Flash: Adobe's own container format is Flash, which supports a variety of codecs. More recent Flash video is encoded with H.264 video and AAC audio codecs, but don't expect all Flash sites to use only those codecs, particularly if the video was created and encoded in years past.
How to Use Your Codecs and Containers
I tend to keep videos on my home server in their original formats, and to use Adobe Premiere Pro CS5 to create videos that are delivered via disc formats; my most recent projects involved Blu-ray delivery.