video transcoding vs encoding

Abstract

Encoding is the process of converting video data from one format to another, while transcoding is the process of taking a video that has already been encoded and converting it to a different format or codec.

Encoding is typically done during the initial creation of a video, while transcoding is often used to convert videos into different formats for playback on different devices or for editing.

If you’re trying to stream video, you’ve undoubtedly heard the terms “encoding” and “transcoding” thrown around — but what’s the difference, and what does it matter?

Essentially, encoding is the act of compressing raw video into a more manageable format, while transcoding refers to taking already-compressed footage and altering it (such as to make it more transmittable to different audiences). They’re very different processes that serve unique purposes, so let’s dive into why they’re both important and how to know when each is appropriate.

First, A Few Definitions

Before we go forward, some definitions you’ll need to know include:

Video encoding: To elaborate on the point above, this term describes the process of converting raw video — which is much too large to broadcast or stream in its original state when a camera captures it — into a compressed format that makes it possible to transmit across the internet.

Without video encoding, there would be no streaming. It’s the first step in delivering content to an online audience because it’s what makes video digital.

Codec: Encoding relies on two-part compression technology called codecs. Short for “coder-decoder” or “compressor-decompressor” (we love a good double meaning), codecs use algorithms to discard visual and audio data that won’t affect a video’s appearance to the human eye. Once video files are a more manageable size, it’s feasible to stream them to audiences and decompress them when they reach different devices.

If you’re confused about the distinction between codecs and encoders think of it this way: encoders are hardware (like Teradek) or software (like OBS Studio) that perform the action of encoding by using codecs. H.264/AVC, HVEC, and VP9 are common video codecs you’ll come across (H.264 most of all), and AAC, MP3, and Opus are examples of audio codecs.

Decoding: Decoding is the act of decompressing encoded video data to display or alter it in some way. For example, a human viewer can’t watch an encoded video, so their device must decode the data and reassemble the “packets” in the right order to display it on a screen. 

Transcoding: Transcoding is an umbrella term that refers to taking already-encoded content, decoding/decompressing it, implementing alterations, and recompressing it before last-mile delivery. Transcoding video might involve making smaller changes, such as adding watermarks and graphics; or much larger ones, like converting content from one codec to another. Actions like transrating and transizing fall under the definition of transcoding.

Transcoding often falls right in the middle along the camera to end-user pipeline. A potential use case would be applying a protocol like RTMP, RTSP, SRT, or WebRTC  for first-mile delivery to a transcoder — which can be either a media server or cloud-based streaming platform — and then transcoding your content into a different codec (or multiple codecs) to make it compatible with the kinds of protocols your audience’s devices support. These include protocols like Apple HLS, MPEG-DASH, HDS, and WebRTC (which is applicable for both first and last mile).

Transmuxing: You’ve also likely heard the term “transmuxing,”which refers to repackaging, rewrapping, or packetizing content. Transmuxing is not to be confused with transcoding because the former involves switching delivery formats while the latter requires more computational power and makes changes to the content itself.

When You Need to Encode Video

You encode video because you need it to be, well, smaller — which means it’s inevitable.

Remember that scene from Willy Wonka and the Chocolate Factory when Mike Teavee jumps in front of the Wonkavision machine and appears in a TV across the room, now two inches tall? The machine took his larger self, broke him down into countless tiny pieces, transmitted them through the air, and reassembled him the right way (adjusting for the TV’s smaller size). Poor Mike was encoded and delivered.

Encoding can compress gigabytes worth of data into mere megabytes. The process could occur in:

  • Mobile apps
  • IP cameras
  • Encoding software
  • Specialized hardware

During a live stream, these tools encode footage as soon as the cameras they’re connected to capture it. The video data is now ready to undergo whatever additional processes are necessary to make it deliverable to various end users.

When Transcoding Video Is Necessary

Transcoding video is a bigger question because encoding happens 100% of the time, but transcoding isn’t explicitly necessary to stream to viewers. 

Why so? It depends on your audience. For instance, live streaming footage from surveillance cameras on a private network, like at a museum, won’t require transcoding because only security guards will see it. All of their tools and screens are on-site or connected to external devices on the museum’s network.

Similarly, if you’re streaming to a broader audience and want to deliver your content using the SRT protocol, you need to be certain every individual you’ll be streaming to uses a device or media player with the right playback compatibility, like Haivision Play or Brightcove.

It’s unlikely that’s a guarantee you can make, though. Imagine you want to live stream a high school graduation event (which are notorious for offering minimal in-person tickets per student, which means some loved ones have to watch from home). You want grandparents in rural Kansas, using a slightly older computer and poor internet, to be able to watch their grandchild cross the stage just as seamlessly as someone else’s aunt and uncle who live in New York with a high-speed connection on the latest MacBook. To make this happen, you’ll need to transcode.

 

What Happens During Transcoding?

Encoding is the first step during this hypothetical live stream. You’ll likely use a more widely supported codec and delivery protocol, like H.264 and Apple HLS, respectively. These options shouldn’t present any problems, but if you want to deliver the content at a 1080p resolution, then our Kansas grandparents are in for a great deal of frustration as they wait for the player to buffer over and over again.

So, you’ll need to change the bitrate to accommodate their limited bandwidth. You can send the stream to a live transcoder that:

  1. Decodes the data
  2. Creates multiple time-aligned streams with optimized frame sizes and bitrates
  3. Possibly converts them to different codecs
  4. Re-encodes them
  5. Adjusts delivery protocols

All to enable adaptive streaming that plays on screens of any kind. The more resolution and bitrate options you provide, the fewer problems viewers will encounter when trying to watch your stream.  

How Do Encoding and Transcoding Affect Video Quality?

You’re understandably curious about how encoding and transcoding affect video quality. It sounds like you’re putting video data through the wringer, so what’s the likelihood it will come out the other end as you envisioned it?

Encoding and transcoding can affect video quality, but don’t have to. As we’ve mentioned, compressing video involves removing data without excessively damaging its quality. If compress a video just the right amount, the final result won’t be perceptible to the human eye; compress a video too much, and you’ll have a pixelated image and glitchy sound.

How Encoding Affects Quality

There are two kinds of encoding:

Lossy compression: Reducing a file size by discarding unnecessary data.

Lossless compression: Compacting files without the above process, therefore maintaining data integrity. ZIP files are an example.

Encoding video, specifically, is an inherently lossy process. It’s important to be aware of your rate-distortion tradeoff: your video’s quality will usually correspond to the bitrate’s size. This is not always the case — the kind of content you’re compressing matters, like live-action footage versus animation — but it’s a good rule of thumb. The best way to compensate for a smaller bitrate is to lower the resolution so images don’t appear overly grainy.

How a Transcoder Affects Quality

There are also three kinds of transcoding (try saying these all five times fast):

Lossless-to-lossless: Compressing a file that hasn’t lost any information and transcoding it in such a way that nothing else is removed a second time. Technically possible, but will likely result in a large file size that streaming or broadcasting is moot. You’ll have to use a high-end transcoder to achieve this result.

Lossy-to-lossy: This kind of transcoding means you’re further degrading an already low-quality video.

Lossless-to-lossy: Compressing a lossless file after altering it, this time removing unnecessary data.

Whichever method you choose will affect your video’s quality, so be aware of what kind of devices you want to stream to and what data you want to add or subtract.

Your Options for an Encoder or Transcoder

Next, where do you turn to for encoding and transcoding? Encoders can be hardware or software that converts video signals coming from camera sensors. You can learn all about what to look for in an encoder here.

Transcoding software can be either local or cloud-based. Local transcoders are slower but you can use them on-site. Cloud transcoders like Wowza’s, on the other hand, are faster and enable you to transcode 4K resolution and stream without worrying about how well it will playback for grandparents in rural Kansas or anyone conveniently living next to a CDN in New York.