DEV Community

Cover image for transcoding vs encoding
alakkadshaw
alakkadshaw

Posted on • Originally published at metered.ca

transcoding vs encoding

In this article we are going to learn about transcoding and encoding.

Encoding is the process of converting raw media data into digital format that is easy to use, store, process and transmitted and played back.

Transcoding is the process of converting already encoded files into a different format. This involves decoding the original file or the encoded file and then re-encoding it into a different format

Transcoding is done to convert an already encoded file into a different format in order to meet specific requirements, such as compatibility with different devices and platforms or network conditions

Image description

In depth Understanding of Encoding

What is encoding

As we have already seen above encoding is the conversion of raw media data into a digital format that can be used to store, transmit and played back on various devices and on different network conditions

The conversion is done using codecs, which are basically algorithms that encode and decode digital data streams

How media is prepared using encoding for consumption

The Raw media files are often very large and require huge processing power and networking conditions to be consumed

These include uncompressed video files and audio recordings, if we take an example the uncompressed HD video takes gigbytes of data per minutes thus making it impractical for storage and transmission of data over the internet

encoding helps by compressing this data into smaller file sizes while maintaining acceptable level of quality. This makes it easier to store the files on the server and also stream them video internet to audiences

Encoding thus is an important step in preparing the media for consumption and ensuring that content creators can devliver their work to audiences all over the world

How encoding helps in compressing and preparing media for consumption

Codecs encode and decode the raw data, these codecs use mathematical algorithms to reduce the file size of media by eliminating redundant and non essential data

Different codecs employ various methods to achieve compression with their own compression efficiency, computational requirement and maintaining the balance between quality and file size.

Explanation of Encoding Codecs

  • H.264 (AVC - Advanced Video Coding): This is a widely used codec that is known for its balance between quality and reducing file size. This makes it a good choice for HD video and high quality audio

  • H.265 (HEVC - High-Efficiency Video Coding): This is the successor of the H.264 compression algorithm. This offers approximately double the compression that is 2x reduction in file size while keeping the quality approximately the same. Thus there is a wide adoption for thue algorithm as well

  • AV1 (AOMedia Video 1): This is an open source and royalty free codec that is developed by the Alliance for Open Media. AV1 has better compression efficiency compared to the H.265 thus making it the ideal choice as it is free and also offers best compression and video quality balance

  • H.266 (Versatile Video Coding or VVC): This is the most modern of the H.266 series of compression codecs. It reduces upto 50% the file size as compared to H.265 without reducing quality

  • EVC (Essential Video Coding): This is designed to provide efficient compression while reducing patent licensing costs 

  • LCEVC (Low Complexity Enhancement Video Coding): This works as an enhancement layer over the existing codecs, improving the quality of video and reducing the file size while reducing encoding and decoding complexity

An Explanation of Algorithms in encoding

  • Lossless Compression: This compresses the data without any loss in quality. While this method preserves quality, it offers less reduction in file size

  • Lossy Compression: This compression discards some data that is less perceptible to human sense resulting in loss of quality. However the reduction is size if far greater than the reduction in quality of media.

Impact of encoding on streaming quality and bandwidth usage

Encoding affects the streaming quality and bandwidth usage by reducing the file size of the streaming media.

Efficient codecs and getting a balance between streaming quality and compression allows you to stream good quality video and also reduce the data transmitted over the internet .

This is also important for streaming video on devices with varying amount of internet speeds and devices with slower internet connectivity

Compressing a video also reduces server storage and cpu resources and also bandwidth expenses

Common Use Cases for Encoding

  • Media Creation from raw footage: whenever the filmmakers or content creators create content, the size of the raw content is quite large in its uncompressed format and highest quality possible. 

Before this content is distributed it needs to be encoded into standardized format that balances quality and file size

  • Compressing media for storage and distribution: When you creates large amounts of data, it occoupies a lot of storage space. You can compress this data to make its file size smaller and thus occupy small size in your computer

  • Encoding for Over-the-Top (OTT) Platforms: Many OTT platforms such as Netflix, Amazon prime and other use encoding ti deliver high quality content across devices to audiences

Best Practices in Encoding for Different Content Types

  1. Understand your audiences and delivery platforms: optimize for the most common devices and network conditions and use codecs that are most widely used.

  2. Select appropriate codecs and settings

  3. Optimize Bitrate and resolution according to your audiences and content quality that you want to provide

  4. Implement Multi-pass encoding

  5. Test Across devices and network conditions to ensure everything is working fine

Image description

In depth Understanding of Transcoding

Converting Already Encoded Data into a Different Format or Bitrate

Transcoding is the process of converting digital media files that have already been encoded into a new format, codec, resolution or bitrate in order to meet specific requirements

Transcoding is different from encoding, encoding transforms raw data into compressed digital format as compared to transcoding where already encoded files are decoded and re-encoded into different formats

The process of Decoding and Re-encoding the files

  1. Decoding: The original encoded media file is decoded into uncompressed format. This step reverses the initial encoding process.

  2. Re-Encoding: The uncompressed media is then re encoded into a different format which is required. 

How Transcoding works

  1. Input Selection: Choose the existing encoded media files that need to be transcoded into a different format

  2. Decoding the original file: the decoder that is compatible with the encoded file is used to decode it to its orignal quality

  3. Re-encoding to new formats: Then compress the media into new format using the resolution and bitrate that is needed

  4. Output Generation: Then newly transcoded file is then stored and is ready for playback and distribution

Image description

The role of Transcoding in CDN

  • Optimizing for different media formats: CDN use transcoding to create multiple versions of the same media ensuring compatibility with different devices and internet speeds like smartphones, tablets and large screen tvs

  • Adaptive Bitrate streaming: With the help of transcoding the CDN can support adaptive streaming protocols such as HLS and MPEG-DASH, this allows seamless switching between different quality levels based on the real time device and network capability

  • Reducing Latency and Improving Use Experience: By transcoding and then caching the content closest to the user geographycally we can minimize latency, reduce buffering and enhance playback quality

Common use-case for Transcoding

  • Adaptive Streaming for varying Network conditions: Adaptive streaming technologies involve delivering content that automatically adjust the quality of the streaming content based on network speeds and device capabilities

    • Multiple quality rendations: Transcoding the orignal media into several versions at different bitrates and resolutions
    • Dynamic switching: The streaming client then detects the network conditions and device capabilities and swithes between these versions dynamically in order to provide the best quality experience to the audiences without any interruptions
  • Format conversion for device compatibility

    • Codec Adaptation: transcoding media files to codec supported by targeted formats these include HEVC for devices that do not support higher tier formats
    • resolution and Aspect ratio adjustments: We can also modify the screen resolution and aspect ratio to suit different device screens and resolutions
    • Audio channel configuration: We can also convert audio tracks to different formats these include 5.1 channel or 2.1 channel suppord sound or strerio sound that is based on harware and internet or streaming plan requirements

Image description

Modern technologies for transcoding

Cloud based transcoding services

  • Elastic resource allocation: Cloud services can provide scalable and on demand services as needed

  • Cost-effective: Pay as go services can eliminate the need to purchase expensive cpu resource and the need to maintain hardware

  • Global availability: CLoud transcoding services are avail all over the world across regions of the world and anyone, anywhere can access these services

Prominent cloud based transcoding service providers

  • AWS Elemental MediaConvert: This services offers file based video transcoding services with broadcast grade features

  • Google Cloud Transcoder API: This provides high quality scalable transcoding technology with support for advanced codecs like AV1

  • Azure Media Services: Enables cloud based media processing, includes transcoding and streaming

Real time transcoding services for real time Live Streaming 

  • Low Latency processing: Real time transcoding minimizes delay between the live event and the audiences. this is imporatant for interactive

  • Scalability: Live events usually consists of thousands of users wathcing at the same time, here scalability of the services is important.

  • Protocol Support: Supporting real time video protocols such as WebRTC, RTMP and SRT is important to deliver the content to the audiences.

Technologies used in real time transcoding

  • Hardware acceleration Utilizing GPUs and specilized hardware encoders like NVIDIA NVENC are used to speed up transcoding process

  • Edge Computing: Performing the transcoding geographically closer to the audience is done in order to reduce latency.

  • Optimized Software Solutions: Custom transcoding software is often used to transcode media for speed and efficiency, software include FFmpeg and others

Example Use cases of transcoding

  • Netflix:

Netflix uses sophisticated technologies to encode and transcode high quality video efficiently

  • Twitch

As a leading live streaming platform twitch uses real time transcoding technologies to transcode raw streams into multiple streams of different video quality for different devices with different CPU capabilities and internet bandwidth capabilities and subscriptions

Aspect Encoding Transcoding
Definition Coverting raw media into compresssed media using codecs Converting already encoded media into raw format and then re encoding it into another format for different requirements like different resolutions, bitrate and codec support by device
Purpose Converting raw media into compressed format for storage, distribution and playback by reducing the file size Adapt existing encoded media for different formats and platforms, network conditions and improve compatibility and optimize delivery of data across internet
Input Data Raw uncompressed data like raw video or audio files previously encoded media files like video and audio files that were previously encoded
Output Data Compressed media files Media files converted into a different file format with different resolutions, bitrate and quality suitable for the specified requirements
Process Steps Compressing media files and converting them into a different file format that is suitable for storage and destribution Decoding the encoded file then re encoding it into new file formats
Timing Initial step afte media creation subsequent step after encoding, it is used when adapting media for specific requirements
Use cases Initial media creation from raw footage, by compressing the media for storage efficient and destribution adapting streaming for varying network condiitions and device capabilities
Impact on Quality Sets the initial quality parameters, quality depends on encoding and codes that are used same as with encoding depends on what codecs you are usign to decode and encode the media files
Resource requirements requires significant resources requires significant resources

Image description

Metered TURN servers

  1. API: TURN server management with powerful API. You can do things like Add/ Remove credentials via the API, Retrieve Per User / Credentials and User metrics via the API, Enable/ Disable credentials via the API, Retrive Usage data by date via the API.
  2. Global Geo-Location targeting: Automatically directs traffic to the nearest servers, for lowest possible latency and highest quality performance. less than 50 ms latency anywhere around the world
  3. Servers in all the Regions of the world: Toronto, Miami, San Francisco, Amsterdam, London, Frankfurt, Bangalore, Singapore,Sydney, Seoul, Dallas, New York
  4. Low Latency: less than 50 ms latency, anywhere across the world.
  5. Cost-Effective: pay-as-you-go pricing with bandwidth and volume discounts available.
  6. Easy Administration: Get usage logs, emails when accounts reach threshold limits, billing records and email and phone support.
  7. Standards Compliant: Conforms to RFCs 5389, 5769, 5780, 5766, 6062, 6156, 5245, 5768, 6336, 6544, 5928 over UDP, TCP, TLS, and DTLS.
  8. Multi‑Tenancy: Create multiple credentials and separate the usage by customer, or different apps. Get Usage logs, billing records and threshold alerts.
  9. Enterprise Reliability: 99.999% Uptime with SLA.
  10. Enterprise Scale: With no limit on concurrent traffic or total traffic. Metered TURN Servers provide Enterprise Scalability
  11. 5 GB/mo Free: Get 5 GB every month free TURN server usage with the Free Plan
  12. Runs on port 80 and 443
  13. Support TURNS + SSL to allow connections through deep packet inspection firewalls.
  14. Supports both TCP and UDP
  15. Free Unlimited STUN

Top comments (1)

Collapse
 
alakkadshaw profile image
alakkadshaw

Thank you for reading. I hope you like the article