Livepeer Studio
Wednesday, May 11, 2022
Education

What is Video Encoding

By
Ivan Kreimer
Ivan Kreimer
10 min read

What is video encoding?

If you've decided to live stream content online, you must do a few things. Setting up the camera is the most obvious part of the process, but that’s only step one.

Streaming your live video content online requires encoding the video so that your company can transmit the data appropriately and transcode it for real-time consumption.

If you don’t know what video encoding is and why you need it, in this article, we’ll explain everything you should know so that you can live stream your content without any hiccups.

What is encoding in video?

In the context of video, encoding is the process of taking raw video content — the content that your video device records — and transforming it into a format that’s compatible with an electronic device.


Encoding vs. transcoding: what’s the difference?

Encoding is not the same as transcoding, despite their similar names. The main difference between both concepts is that encoding refers to the process of taking your video content and making it easy to consume on a computer, phone, or tablet. On the other hand, transcoding takes an encoded video and decodes it in different sizes, resolutions, bitrates, and more.


Put in another way:

  • Encoding makes your video recording consumable by computers and other devices
  • Transcoding adapts your video's size, resolution, and bitrate for each viewer's Internet bandwidth


Read More: Video Transcoding: What is it, why is it important, and how can I do it?


Why is encoding necessary?

At first, the need for encoding seems a bit redundant. You may think to yourself that video doesn't need to be changed from the format it's recorded. After all, when you record a video with your phone, it's immediately ready to playback afterward. That happens because your phone automatically encodes and decodes your video after it's recorded.

At some point, you must have downloaded a video that wasn't consumable on your computer or phone. You may recall the problem was tied to the "codecs" or the "format." Before we get into these concepts, we need to go over the details of what makes encoding necessary.

Video cameras record content so that each frame is a picture. Therefore, a video is a compilation of still images, much like hand-drawn animations.

The problem with this setup is that each second of a video is made up of 24 to 60 frames (also known as “frames per second” or “fps”). Multiply your recording’s fps by its amount of seconds, and you will get the total number of frames per video. Multiply that number by the size of each frame (which can vary from a few dozen to hundreds of kilobytes, or even megabytes), and you will get a massive number that will be impossible to playback and transmit online.

To overcome this issue, you encode your recording so that each frame is smaller and easier to play. Better yet, the video will be smaller while losing little to no quality.

Still, this explanation doesn't explain everything about encoding, so let's take a deeper dive into the technicalities of encoding.


How does encoding work?

Imagine you have recorded a two-minute video on your camera. When you connect your camera to your computer, the camera’s software will automatically:

  1. Use a codec (short for “coder/decoder” or “compressor-decompressor”) that compresses the file
  2. Format the new compressed file into a video format (or “container”)

These two steps are what encoding is all about. Let’s go over them individually to understand this even better.


What is a codec?

Codecs are algorithms that transform a raw video file into an asset that you can consume on a device like a computer or a phone. What makes codecs crucial in the encoding process is that they compress a video file by using either of the two compression formats:

  • Lossless, which leaves the video intact, making the file heavier but higher-quality
  • Lossy, which reduces the video in a non-noticeable way so that it’s smaller and easier to consume and transmit online

As the acronym suggests, codecs compress the file, so it’s easier to store and transmit, but they also decompress it to make it compatible with other devices. Some codecs can compress both video and audio files, while some can’t. In any case, codecs are always paired together so that you can compress both parts simultaneously.


There are dozens of codecs for each of the two compression formats, each with benefits and disadvantages. The five most popular ones are the following:

  • H.264 (AVC): The most popular and widely supported codec for live streaming.
  • H.265 (HEVC): The replacement for H.264 can provide two times the performance of its predecessor, despite not being as widely supported.
  • VP9: An open-source, royalty-free video codec that leverages lossless compression. It’s better suited for ultra-high definition (UHD).
  • AV1: Another open-source, royalty-free video codec that brings consistent, high-quality video.
  • H.266 (VVC): The successor of H.265 is predicted to boost compression rates by 50%. Just like its forebear, it’s yet too early to see if it’s as good as it’s deemed and still lacks wide support.

H.264 and H.265 are perfect for high-definition videos intended for live streaming. The drawback? They come with a costly license fee.

AV1 and VP9 are the best free alternatives capable of providing similar performance to the previous ones, with VP9 better suited if you plan to target Android devices.

What is a video format?

An encoding video format is a file that contains (hence its name) the compressed audio and video file. It also includes the metadata, which allows the video player to use the audio and video codecs properly, among other things.


Although a video container and its extension aren’t necessarily the same thing, they are often treated as equal, with some of the most widely-used ones being:

  • AVI: Popular due to its high compatibility with both Windows and Mac operating systems. It also keeps the audio quality high after compression. The only drawbacks are that it’s impossible to set and modify aspect ratios manually and that the compression results in visible quality losses.
  • MKV: An open-source format that offers lossless compression and high resolution. Sadly, few mobile players support MKV while it offers a slow loading speed. Its compression also generates large video files.
  • MOV: Famous for offering laser-sharp quality and high compatibility with other video formats. However, its lossy compression leads to poorer quality and a large file size.
  • MP4: The best format for file size efficiency, loading speed, and compression. It’s light on bandwidth, guarantees lossless compression, and supports overlay texts. Sadly, it depends on different codecs for best results and has relatively high loading times.
  • WebM: A Google-backed video format crafted for web videos. HTML5 supports the format and focuses on keeping clips small. Despite using lossless compression with small file sizes, the problem is that it results in relatively low-video quality, offers limited support for mobile devices, and has no support for Mozilla Firefox.

Just as it happens with codecs, each encoding format carries its benefits and challenges. Some offer better compatibility with video players, while others focus on quality instead of compression.


How to implement encoding for live streaming?

Encoding a video is a relatively straightforward process that requires some planning to find the right codecs and formats for your needs. But when it comes to encoding for live streaming, things get a bit more complicated.


The first point is that the video content needs to be encoded fast so it can then be transcoded and transmitted online (what we call “streaming”). The compression format must be lossy to enable fast encoding. Sure, the quality may not be the highest, but it’s the most convenient for speed.

The codecs previously mentioned offer lossy compression, the most widely used being H.264.

Most smartphones come with a built-in encoder, making it easy to live stream from social media and messaging apps. However, specific encoding software and hardware may be necessary for companies that need high-quality live streaming.

Imagine that you want to live stream an event in a physical location, like a retail shop. You set up your cameras, lights, microphones, computer, and Internet connection.

Within the live streaming workflow, the encoder takes the raw digital data from the cameras and microphones and transforms them to be transcoded and appropriately streamed.

Since encoding live-streamed content requires a higher capacity than what we mentioned so far, you will need to set up a special hardware or software encoder.

Roughly speaking, encoding hardware is suited for professional broadcasting (think CNN or the BBC). Although it provides the most reliable and faster results due to the machine focusing solely on encoding, its costs and lack of upgrading options (e.g., switching) aren’t worth it for most streamers.


Live streaming encoding software offers a similar capacity at a much lower price. Even if the latency is higher, encoding software represents an effective alternative. There are many options available, three of the most popular being:

  • OBS Studio: A free, open-source, easy-to-use platform with real-time video and audio capturing and mixing and more.
  • Wirecast: Starts at $599 (one-time fee) and offers unlimited sources, multiple bitrate streaming, among other things.
  • vMix: Compatible for Windows only, this encoder offers a wide range of features and it’s free to use for up to four inputs and video up to 768 x 576 resolution. Its paid plans offer up to 1,000 inputs and 4K resolution.

When selecting an encoding software, you need to guarantee it meets the following criteria:

  • Compatible with your setup, including your computer, microphone, and camera
  • Offers some editing and mixing capabilities
  • Sustains all your inputs
  • Cost-effectiveness

Once you have chosen and set up your encoding software, you must connect it with your transcoding solution, such as the one Livepeer Video Services offers. This last part is crucial, as no matter how good the encoding may be, if it’s not properly ingested, packaged, and transported through the servers, your viewers will not enjoy your live stream.

To learn more about how crucial transcoding is and how you can set it up, check our guide on the subject:

Read More: Intro to Transcoding


How much does encoding cost?

Encoding costs are what accountants call “fixed costs” because they don’t change depending on your needs. The opposite is true with transcoding, as the more content you transmit, the more you will spend.

Consequently, your costs will depend on the encoding hardware or software you use. Fortunately, encoding doesn't cost as much as transcoding. And since encoding is crucial for live streaming, you should invest adequately in your hardware or software.

To give you an idea of what encoding hardware costs, here are three popular options and their costs:

You may also need to buy a video studio recorder to save the streamed content as encoders aren’t too good at this task (except when you only use them as a backup).

The options shared above already explain what you can expect to pay with regard to software. Higher-end solutions offer a mix of monthly plans (most charge between $9 to $50 a month) to high one-time fees — anywhere from $60 to $1,200.

We recommend you use OBS, which is free and popular. Better yet, you can integrate it with Livepeer Video Services in five easy steps as we explain in the following tutorial:



What did you think of this tutorial? Give us any feedback on how it can be improved and send over any questions you might have by emailing us at hello@livepeer.com. We’d love to help you stream using Livepeer.com!