This is a question that appears frequently within the media industry, which is understandable as almost every form of digital media seen today uses codecs and you will hear about them often. Unfortunately on the surface they appear to be complicated and get many people confused but they shouldn’t be ignored, and once you get down to it they really aren’t all that bad.
Codecs put simply, are methods for encoding and decoding digital data, specifically compressed data. They squish files essentially, making them very useful today when uncompressed video or audio can take up tons of virtual space that can bring workload to a crawl when your transferring all at once.
The word codec is literally shorthand for COmpressDECompress. Compressing files meaning to make them smaller, and decompress means to play back compressed files.
There are many codecs available but most are already outdated and it only takes one quick Google search to reveal which ones are currently leading. This isn’t to say a single codec will do absolutely everything but it makes selecting the one you want much easier. Common codecs within the video industry are H.264, ProRes, ProRes 4444, MPEG2, AVC, within audio WAV, AIFF and AAC are just a few.
Each codec will perform compression differently. The first consideration is lossy and lossless compression. Lossy codecs will discard data (cleverly mind you) to decrease the file size drastically but normally have subtle but visible results. While lossless will only remove data to an extent; just before the removal process becomes visible, meaning the file is smaller then the original with no visible quality loss. Its also worth mentioning most people will work down the chain for obvious reasons; like editors who will normally work with lossless or uncompressed files (e.g. ProRes) can then export video using a lossy codec better optimised for web use and sharing (e.g. H.264).
The last step is choosing the “container” to store your video in, this is what confuses most people. The container also means the format or .extension that holds your file. Common containers are .mp4, .mov, .mp3, .wmv, etc. This is often mistaken as being the file type within the container, different file formats exist is because not all containers will except every type of codec. The .mp4 and .mov formats are currently at the top for video as they accept the biggest variety of video codecs.
To put that last paragraph into visual context. When you click a video or audio file on your desktop a theoretical box is opened (the .mp4 or .wav), that was able to fit the compressed content inside (the H.264 or MPEG). The quality of what comes out is all dependent on the codec settings not that it is a .mov or .mp4 file.
To summarise: using the industry of video production. Raw footage enters the camera and is kept either as uncompressed or lossless footage, which is then compiled into compatible editing software. This footage will now be edited and exported using the appropriate codec for delivery, whilst choosing an appropriate container to hold this codec. The compressed video within its container gets sent or uploaded as a package to the correct place, whether it be YouTube or a client email. Should anyone click on this video the codec decompresses the video packet, audio and all, which should then play.
https://www.youtube.com/watch?v=WpBjGUlBTHU – Not the best in editing quality but provides one of the best step by steps of what a codec is.