Video Transcoding: A Practical Guide

Typically, videos, especially the high-quality ones or those with a lot of footage, are large files that slow down page loads during delivery. This article explains how video transcoding works to overcome that issue and suggests tips and hints for adoption of the transcoding approach. The topics are as follows:

What Is Video Transcoding?

The transcoding process creates a copy of a video file in a format that’s suitable for playback on your platform of choice at the quality and in the file size you desire. In a nutshell, transcoding decodes encoded data into an intermediate format and then encodes it into the target format.

When Should You Transcode Video?

By transcoding video, you accomplish the following:

  • Simultaneously create a set of time-aligned video streams, each with a different frame size and bitrate.
  • Convert codecs and protocols for a larger audience.
  • Package those internet-friendly streams into adaptive streaming formats, such as HLS, enabling playback on almost any screen.

Transcoding is essential for video delivery and streaming if—

  • Your software or device does not support the format of your footage. In that case, transcoding is the only solution.
  • The original footage uses up too many system resources, as in the case of a huge 3K video attempting to play on a mobile device. As a resolution, you must transcode the file for a lighter format.
  • Your video format, such as HD DVD, is out of date. Transcode the media file to a modern format and you’ll be home free.

How Do You Transcode Video?

Even though the video-transcoding process varies from case to case, a few practices are in popular use. Here is an example:

Step 1: Inputs

Two inputs are required:

  • Details of the input file or format, which you can determine by analyzing the transcoded media.
  • The complete set of parameters for the output, which you can access from the rules within the media’s supply-chain system. Alternatively, you can derive it from the metadata according to the variables in the workflow engine.

Step 2: Transcoding pipeline

The pipeline involves processing all the components, such as video, ANC, and audio, in the transcoded file. When transcoding starts, the metadata is split as needed among the components. The transcoder analyzes the file and instructions and then configures the pipe. To shorten the process, concatenate the steps involved instead of performing them sequentially.

Here is an example of how transcoding works with one component—a video:

  1. Demux the input: Extract all the compressed data from the package, the wrapper, or both.
  2. Decode the video: Decompress the file as close as possible to the original uncompressed frames.
  3. Process the video: Scale, interlace, deinterlace, or perform advanced image-processing steps that change picture elements to improve the perceived result of encoding.
  4. Encode the video: Do that with the required destination codec.
  5. Mux the video: Pack it into a wrapper or package, combining the video with other components as required.

What Are the Types of Video Transcoding?

There are three main types:

  • Standard transcoding, which involves changing the video or audio to transcode a video or stream. For example, streaming a digital conference usually requires working with IP cameras set within a conference space. If those cameras use the Real Time Streaming Protocol (RTSP) and cannot create a video stream suitable for online playback, you can convert the content into an adaptive bitrate stream by transcoding the video.
  • Transsizing (image scaling), which involves resizing a video frame. For example, you can lower a 4K resolution to 1,080 pixels.
  • Transrating, which changes the bitrate without modifying the video content, format, or codec. For example, to ensure that the video can fit into less storage space or can be broadcast over a lower bandwidth connection, reduce an 8-Mbps bitrate to 3-Mbps.

Transrating comprises three types:

  • Lossless to lossless, which maintains the quality of the video across formats, enabling you to take advantage of more effective hardware or compression algorithms.
  • Lossless to lossy, which reduces the quality of the video but yields a smaller and faster file or one that’s compatible with the requirements of a certain platform, browser, or player.
  • Lossy to lossless, which ensures that the video quality does not deteriorate further during the conversion process. Note that, by adopting this process, you cannot regain the data and quality previously lost through compression.

What Are the Best Practices of Video Transcoding?

Take the steps below to produce high-quality video content through transcoding.

1. Set a two-pass variable bitrate (VBR).

Encode high-quality videos with various scene types through a two-pass VBR. Unlike the regular VBR and CBR [constant bitrate], a two-pass VBR features two encoding stages:

  • The first stage computes the ultimate bitrate required for all the keyframes in the video.
  • The second stage renders the entire video based on those bitrates.

A two-pass VBR chooses keyframes for the scene changes, with the keyframe’s encoding actions relying on the previous and subsequent keyframes. That makes for an effective bitrate for rendering top-quality, prerecorded—but not live-streaming—videos.

2. Select the right bitrate.

Be sure to pick the correct bitrate before encoding video. Such a practice is particularly ideal for CBR-encoded videos that encode at the highest bitrate. Also, keep your VBR the same as the pixel width of your video.

Additionally, the correct bitrate varies according to the kind of video you are encoding. Animated videos play well even at average-to-low bitrates, whereas action movies or videos with dynamic adjustments typically encode at higher bitrates to enhance the quality.

Blocking artifacts, also called pixelations, are formed by an encoding obstruction, which negatively impacts quality during compression. To minimize those artifacts, advance the effectiveness of High Efficiency Video Coding (HEVC) by setting the vertical and horizontal frame-size measurements as multiples of 16.

3. Develop adaptive sets.

For a smooth video playback, create adaptive sets, which are transcodes of the same video with several bitrates. To do that, use adaptive streaming tools to produce a video copy that captures the viewer’s connection speed for a sleek viewing experience.

How Do You Transcode Video With Cloudinary?

Transcode videos the smart way by having Cloudinary automatically select the best codec and the most suitable video format for you. That task, originally slated for images only, now also applies to videos as an integral part of Cloudinary’s video APIs.

Besides, Cloudinary delivers the appropriate video format and codec (H.264, HEVC, or VP9) for the viewing device and browser—a future-proofed capability that will accommodate next-generation codecs like AV1. That’s peace of mind exemplified.

To add the capability of automatic, browser-based format and codec selection, simply set the fetch_format parameter to auto (f_auto in URLs). Most Chrome users would then receive a VP9-encoded WebM file; Safari users, an HEVC-encoded MP4 file. In case those formats do not work on the requesting browser, Cloudinary delivers the video as an H-264-encoded MP4 file, which plays well in almost all browsers.

On top of all that, you can combine the automatic format-selection feature (f_auto) with Cloudinary’s automatic quality feature (q_auto) for even more impressive results. With q_auto, an intelligent quality and encoding algorithm analyzes video content to pinpoint the best quality-compression level and optimal encoding settings, ultimately delivering a premium-grade, small-sized video. A win-win, bar none!