Edge Academy


Transcoding is the process of converting an audio or video file from one encoding format to another in order to increase the number of compatible target devices a media file can be played on.


Encoding and transcoding are sometimes used interchangeably, but the two processes, although closely related, are indeed different.

Encoding is the process of compressing video and audio files to be compatible with a single target device. Transcoding, on the other hand, allows for already encoded data to be converted to another encoding format. This process is particularly useful when users use multiple target devices, such as different mobile phones and web browsers, that do not all support the same native formats or have limited storage capacity.

Encoding is a naturally lossy process, meaning that it causes a certain amount of data to be discarded and ultimately decreases audio and video quality. Encoding can use lossless compression, but it results in decreased compression rates and increased media file sizes.

With that in mind, there are three types of transcoding:

  1. Lossy-to-lossy: This is the least ideal form of transcoding. It means you already have a file with decreased quality and transcoding causes the quality to degrade even further. The only reason to use this form of transcoding is to lower the bitrate and save storage space on portable players.
  2. Lossless-to-lossless: By taking advantage of better compression and hardware support a file can be losslessly compressed. This type of transcoding is useful for converting to new formats without losing quality, but the resulting files are often too large to send to portable devices.
  3. Lossless-to-lossy: This transcoding method causes less quality loss than lossy-to-lossy and produces file sizes small enough for portable devices. You must maintain archives of losslessly compressed files to truly leverage this transcoding method.

There is no such thing as lossy-to-lossless transcoding. Once data and quality have been lost during the encoding or transcoding process they cannot be regained.

How Transcoding Works

Transcoding and encoding should not be confused with transmuxing which only converts the container format such as MP4 and FLV (Flash). On the other hand, video and audio files are compressed by codecs such as VP6 and H.264. However, similar to transmuxing, transcoding can be done using FFmpeg, a popular open source software designed to handle all video and audio formats. Converting any media to a standard H.264 mp4 can be done with a simple command:

ffmpeg -i "sourceVid.mov" "transcodedVid.mp4"

The above command will take sourceVid.mov, which has already been compressed and encoded, decode it, and reformat it into an MP4 file using the H.264 codec. The resulting file will be named transcodedVid.mp4.

You can also setup your own stream and offer different resolutions in real time using FFmpeg. Setting up a stream requires a more complete understanding of the software, but here is a sample command:

ffmpeg -i rtmp://server.ip/app/1080 -vcodec libx264 -preset veryfast -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -b:v 3000k -maxrate 3000k -bufsize 3000k -s 1280�720 -sws_flags spline -r 30 -acodec copy -f flv rtmp://server.ip/app/720

The above command takes an RTMP stream and encodes it using x264, a H.264 encoder. The additional options included in the command set the bitrate, buffer, framerate, and resolution of your output, which will be in an FLV (Flash) format.

Examples of Transcoding

Transcoding is a powerful process that is leveraged by major streaming organizations such as Twitch, which actually uses both FFmpeg and its own TwitchTranscoder to stream video and audio on its platform.

The world’s largest provider of user-generated videos, YouTube, receives over 300 hours of uploads every minute—and it uses transcoding to make those videos available in 5+ different qualities and 5+ different formats. This means the original uploaded content can be transcoded into over 20 versions. YouTube kicks off the encoding and transcoding process as soon as the original upload is complete, which is why new videos are often only available in low-resolution until the higher-res videos are transcoded.

Transcoding content at the edge

StackPath’s edge compute products do not offer transcoding out of the box. However, users can install software such as FFmpeg on our virtual machines and containers to transcode streams and video/audio. This lets you transcode at the edge and leverage our content delivery network to deliver your transcoded media all around the world in near real time.

Key Takeaways

  • Transcoding and encoding are often and incorrectly used interchangeably; encoding is the original compression of data and transcoding is the process of decoding, reformatting, and re-encoding data.
  • Lossless-to-lossless transcoding is the best method for converting large, archived media files and lossless-to-lossy transcoding is the best method for delivering compatible content to portable devices.
Related Products
Request Demo

Have questions? Chat now with the live chat button on this page or request a demo from our edge experts.

Request a Demo
Get an Advantage

Stay informed of the latest edge news, updates and solutions.