Encoding refers to several different processes in the content chain. The principles of encoding are the same for all the processes, the difference is how the principles are applied, and considerations around the encode depend on which process you’re talking about. To try and make a rather complex more tangible we’ll therefore give a summary of the most important common principles regarding compression, codecs, and other necessary information to be able to understand the process of video encoding.
Types of compression
In the encode process, you always try to keep the video quality as high as possible using the least possible data. To reduce the amount of data, there are three types of compression:
Lossless means that all and any data that previously has been removed can be recovered completely. In the non-video world, a ZIP-file is the best and most well-known example of lossless compression, where similar techniques are used in video encoding.
- Visually lossless
Visually lossless means the original data can’t be recovered, but the result is visually identical. This compression relies on models of how we perceive video and generally how the human eye works.
Lossy is compression where some of the “quality” of the image is lost. Depending on the application and level of compression, this may be impossible for the viewer to notice. Lossy compression is used in a vast majority of video workflows where, generally speaking, the further we move from the content origination towards the viewer, the more compression is used.
What are codecs?
A video compression technology called codec is used to encode/decode and compress/decompress video. They simply allow us to tightly compress a bulky video for delivery and storage. The codecs apply algorithms to the video and create a facsimile (a copy) which is shrunk down for storage and transmission and later decompressed for viewing.
A video is made up of several still images (or frames) played in sequence. Therefore, most codecs use a combination of intraframe and interframe compression.
- Intraframe compression
Intraframe compression is, at a high level, the same as the encoding used on digital photographs. There are some things the eye can’t see in moving images that it will instil, which can be exploited. Therefore, intraframe compares differences in pixels in the horizontal and vertical planes of the image and, normally in blocks of pixels, stores the variance between them rather than the full data for each pixel – you can see those blocks sometimes when you get a data interruption in a video stream.
- Interframe compression
Interframe compression does the same thing but between the frames, based on the principle that in many scenarios, there isn’t a massive change in the image between frames except at scene changes. Several frames are therefore grouped into a “group of pictures” (GOP), and, again, the variance between rather than the whole image data is stored. That number of frames is typically “fixed GOP length” but can be “variable GOP length” in some applications
Changing between codecs
When changing between codecs, or “transcode”, you have to go back to the baseband - i.e. each time we decode and encode the video. Where lossy compression is used, the concept of “generational loss” becomes an issue. Generational loss refers to the loss of quality between subsequent copies or transcodes of data. Different codecs have different generational loss performance, but as a general rule, to preserve quality, we need to reduce the amount of transcoding applied to the video through the content chain. Due to the generational loss, it’s important to make considerations when thinking about the different encoding process and codecs to use.
For example, going back to GOPs. In editing, if we only use intraframe encoded material as our source, we can “copy” frames we don’t change directly to the output, only decoding and re-encoding frames that we’ve manipulated. However, if we use interframe encoded material, we need to decode and re-encode entire GOPs and, given that we probably need to maintain constant GOP lengths, this means re-encoding all used frames, introducing a generation of loss. Therefore in editing, and especially where turnaround time (speed) is important, intraframe codecs are often preferred.
Speed vs. Quality vs. Efficiency
Another important thing to note is that encoding tends to be a factor of speed vs. quality vs. efficiency (level of compression). Often at times, you’ll have to make a compromise where if you want something encoded quickly, you’ll need to choose between either quality or efficiency - if you want both of them you’ll need a lot of horsepowers, thus becoming expensive. If you want quality and efficiency, it’s either going to take a lot of time or a lot of horsepowers.