Video transcoding is the process of converting a video file from one format to another. It is essential for smooth media playback. Transcoding can involve changing the file’s encoding format, resolution, bit rate, or other parameters. The goal is to make the file compatible with different devices, platforms, or internet connection speeds.
Transcoding works by:
- Decoding the encoded data into an intermediate format
- Encoding it into the target format
- The process may also include transrating and transsizing/image scaling.
Example use cases of transcoding include:
- Converting a Windows Media file to MP4 so it can be played on a portable device.
- Adjusting the bitrate so large file size video types like 4K can be converted to high-quality video stream viewing.
- Converting files captured with a camera to lower resolution, lower size “proxy” files.
- Transcoding high quality finished video from an editing format like Apple ProRes to a delivery format like H. 264.
Transcoding best practices include setting a two-pass variable bitrate (VBR), selecting the right bitrate, and developing adaptive sets.
This is part of our series of articles about video formats.
In this article:
- When Should You Transcode Video?
- How Do You Transcode Video?
- What Are the Types of Video Transcoding?
- Video Transcoding Example Use Cases
- What Are the Best Practices of Video Transcoding?
- How Do You Transcode Video With Cloudinary?
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:
- Demux the input: Extract all the compressed data from the package, the wrapper, or both.
- Decode the video: Decompress the file as close as possible to the original uncompressed frames.
- Process the video: Scale, interlace, deinterlace, or perform advanced image-processing steps that change picture elements to improve the perceived result of encoding.
- Encode the video: Do that with the required destination codec.
- 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.
Video Transcoding Example Use Cases
Here are some examples of transcoding use cases:
Converting a Windows Media file to MP4 for Portable Device Playback
The ubiquity of portable devices, such as smartphones and tablets, has driven a need for universally compatible video formats. Windows Media files, while once popular on PCs, are not natively supported on many of these devices.
By transcoding a Windows Media file to the more widely accepted MP4 format, users ensure that their videos can be played seamlessly across a broader range of devices, including iOS and Android smartphones, tablets, and many other MP4-compatible platforms.
This conversion increases accessibility and simplifies sharing and playback without needing specialized apps or software.
Adjusting Bitrate to Make 4K Video Streamable
4K videos, known for their ultra-high-definition clarity, come with significantly large file sizes due to the extensive data required to represent their detailed imagery. Streaming such heavy files directly can cause buffering issues, leading to a subpar viewing experience, especially for viewers with limited bandwidth.
By transcoding and adjusting the bitrate of these 4K videos, the file size can be reduced, making them more suitable for streaming without compromising excessively on visual quality. This ensures that viewers can enjoy high-quality video streams without frequent interruptions or long loading times.
Creating Lower Resolution “Proxy” Files from Camera Captures
When dealing with high-resolution footage directly from cameras, video editors often face challenges in real-time playback during the editing process due to the hefty data loads. Transcoding these high-resolution files into lower resolution, smaller “proxy” files can alleviate this problem.
These proxy files retain the same temporal characteristics as the original footage but are much easier to handle and manipulate in editing software. Editors work with these lighter files during the editing process and, once completed, the final edit can be conformed back to the original high-resolution footage for final export.
Transcoding Apple ProRes to H.264 for Delivery
Apple ProRes is a high-quality, lossless codec primarily used in professional video editing environments for its superior color fidelity and flexibility in post-production. However, due to its large file size, it’s not optimal for wide-scale distribution or streaming on the internet.
Before delivering the final video product to audiences or clients, it’s common practice to transcode from ProRes to a more compressed codec like H.264. H.264 retains a good balance between file size and quality, making it an excellent choice for delivery, especially for online platforms and streaming services.
This conversion ensures that the final product is accessible and streamable to a broad audience without requiring vast amounts of bandwidth or storage.
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
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!