What is Just-in-time encoding?

July 17, 2024
6 min
Video Education
Share
This is some text inside of a div block.

Just-In-Time encoding, also known as Just-In-Time packaging, is a method where video content is encoded and packaged in real-time, just before delivery to the viewer.  It is different than traditional encoding, where videos are pre-encoded into various formats and stored on servers.

JIT encoding processes the video content only when a request is made by the viewers. This real-time encoding ensures that the content is processed according to the viewer’s requirements such as bandwidth and device capacity with other specific requirements.

The term packaged is mentioned here, to understand Just in time encoding. Let us start by understanding what video packaging is.

What is a video packaging in just-in-time encoding?

Video packaging is also known as video encoding it is a process of converting digital video content from one format to another, a step in ensuring compatibility and performance across various platforms and devices providing a better watching experience.

Key Aspects of Video Packaging:

  • Format conversion: Ensures the video can be played seamlessly across all intended platforms and devices by changing its format.
  • Compression: Reduces the file size without significantly affecting video quality, making it easier to store, transmit, and stream.
  • Optimization for delivery: Adjusts resolution, bitrate, and other parameters to ensure smooth playback, even on slower internet connections.

Now that we understand what video packaging is, lets us dive deeper into understanding more about different modes of packaging.

Different mode of packaging

Linear packaging

In the linear packaging process, live video is first converted into an MPEG-2 Transport Stream (TS) and then processed by a packager. This packager divides the stream into smaller segments, creating individual files.

These files are either used as the source for a content distribution network (CDN) or transferred to the CDN's origin server. The CDN then takes over the task of delivering these segments to the end users.

To improve efficiency, the CDN replicates the segments at its edge locations. This approach reduces the need for every client request to travel back to the central network and the packager, thus optimizing the delivery process and decreasing network congestion.

How linear packaging works

Drawbacks of linear packaging

While linear packaging has been a traditional method for video delivery, it presents several challenges in today's streaming landscape:

  • Latency: The process of segmenting, packaging, and distributing content can introduce significant latency, particularly for live events. This delay can be detrimental to the viewer experience.
  • Inefficient resource utilization: Creating and managing numerous small segments can be resource-intensive, both in terms of storage and processing power.
  • Limited flexibility: The fixed-length segments and packaging format can restrict adaptability to changing network conditions and viewer preferences.
  • Difficulty in Ad insertion: Inserting ads into linear streams can be complex and requires precise synchronization, which can be challenging to achieve.
  • Increased CDN load: Distributing numerous small segments places a higher load on the CDN, potentially impacting performance and costs.

File-based packaging

File-based packaging, involves converting a file from its original format into an HTTP-compatible format. File based packaging is mostly used for VOD (Video on Demand) where pre-recorded encoded content is converted from one format into an HTTP deliverable format.

For instance, a TS file format designed for legacy TS streamers can be transformed into an HLS segmented format. In offline packaging, all the segments and playlists are pre-created and stored, ready for future delivery.

How File-based packaging works

Drawbacks of file packaging in streaming

While file packaging has been a traditional method for distributing video content, it presents several challenges in the modern streaming landscape:

  • High latency: File-based delivery often results in higher latency compared to streaming protocols, as the entire file must be downloaded before playback can begin.
  • Inefficient bandwidth utilization: File packaging can be inefficient as it requires downloading the entire file, even if the user only watches a portion of the content.
  • Limited scalability: File-based delivery can struggle to handle large-scale, concurrent streams, leading to buffering and quality issues.
  • Difficulty in adaptive bitrate streaming: Adapting the bitrate based on network conditions is challenging with file packaging, as it requires multiple file versions.
  • Increased CDN load: Distributing large files can put a strain on CDNs, impacting performance and costs.

Edge packaging

Edge packaging is particularly favoured for live streaming delivery, as it helps reduce core network bandwidth by minimizing the load on central servers by moving the packager to an edge site, co-located with the CDN, the same packaging functions are performed closer to the end-user. This approach maintains the efficiency of packaging processes while optimizing network performance and reducing latency.

How Edge packaging works?

Drawbacks of edge packaging

  • Increased complexity: Implementing and managing edge packaging infrastructure can be complex and requires specialized expertise.
  • Higher costs: Deploying and maintaining edge servers can increase operational costs compared to traditional centralized packaging.
  • Dependency on edge network: The performance of edge packaging heavily relies on the quality and capacity of the edge network, which can vary geographically.
  • Content management challenges: Coordinating content updates and consistency across multiple edge locations can be difficult.
  • Security risks: Distributing content closer to the edge introduces additional security challenges that need to be addressed.
  • Why traditional encoding is tough in this video centric world?

    Traditional encoding is tough to work with due to the need to support a wide range of devices, each requiring different resolutions and bitrates. High-quality streams demand more bandwidth, and adaptive bitrate (ABR) streaming must handle varying network conditions. Managing multiple versions of videos increases storage and delivery costs, and the time-consuming process led to delays.

    How just-in-time encoding is different than the traditional encoding process

    Traditional video processing involves pre-rendering a video into multiple formats for different devices and network conditions. This process, while ensuring compatibility, demands substantial storage and computational resources. Furthermore, it lacks the flexibility to adapt to dynamically changing network conditions.

    In contrast, Just-in-Time (JIT) encoding offers a more efficient approach. By processing a single master video file only when requested, JIT significantly reduces storage requirements and computational overhead. Moreover, it empowers real-time adaptation to varying network conditions, delivering optimal video quality for each viewer.

    This dynamic approach not only enhances viewer experience but also optimizes resource utilization.

    Comparison between Traditional and Just in time encoding

    Balancing storage and bandwidth with just-in-time processing

    JITP addresses storage and bandwidth challenges by dynamically encoding video content now it is requested by the viewer, rather than storing multiple pre-encoded versions. This approach optimizes both storage and bandwidth usage:

    Storage Efficiency: Instead of storing numerous video files like what happens in traditional encoding method in JITP things are bit different it stores a single high-quality master copy. When a user requests a video to play, JITP encodes it on-the-fly into the appropriate format and resolution required reducing the overall storage consumption.

    Bandwidth Optimization: JIT encoding videos in real-time based on user device and network conditions this steps ensures better streaming quality while minimizing bandwidth consumption. This adaptive streaming capability adjusts video quality dynamically to match available bandwidth, delivering a seamless experience for the viewers even with different network speed and device compatibility.

    How does just-in-time encoding works technically?

    Step 1: Source content storage:

    The Process begins with the storage of high-quality source video files in a central repository. These files, often in a mezzanine format (like ProRes or DNxHD), serve as the pristine source material for subsequent encoding.

    Step 2: Request handling and decision making:

    When a user initiates a request to stream a video, the JIT encoding system assesses several factors to determine the optimal encoding parameters:

    Client device characteristics: The system identifies the type of device (e.g., smartphone, tablet, smart TV) and its capabilities such as screen resolution, supported codecs, and processing power.

    Network conditions: It evaluates the current network bandwidth and latency to gauge the appropriate bitrate and streaming protocol (e.g., HLS, MPEG-DASH) for seamless playback.

    User preferences: Optionally, user settings or preferences may influence encoding decisions, such as language preference or accessibility features.

    Step 3: Real-time encoding:

    Once the system has gathered relevant information, it proceeds with the real-time encoding process:

    Transcoding: The JIT encoding system transcodes the original source video into a format and bitrate optimized for the specific device and network conditions identified earlier.

    Adaptive bitrate streaming: For adaptive bitrate streaming, multiple versions of the video may be generated simultaneously at varying bitrates (e.g., 720p, 1080p) to accommodate fluctuations in network speed without interrupting playback quality.

    Codec conversion: If necessary, the system converts the video into a codec compatible with the client device, ensuring efficient decoding and playback.

    Step 4: Packaging and delivery:

    Following encoding, the JIT system packages the transcoded video into the appropriate streaming format:

    Segmentation: The video stream is segmented into chunks or segments, typically a few seconds long, to facilitate adaptive bitrate streaming. Each segment is encoded at different quality levels to provide smooth transitions between bitrates during playback.

    Manifest file generation: A manifest file (e.g., .m3u8 for HLS) is generated that contains metadata and URLs pointing to each segment. This file guides the client device on how to retrieve and playback the video segments seamlessly.

    Step 5: Content delivery network (CDN) integration:

    To ensure efficient delivery, the JIT encoded video segments and manifest file are distributed across a Content Delivery Network (CDN):

    Edge Caching: CDNs (Content Delivery Networks) cache video segments at edge servers geographically closer to the end-users, reducing latency and improving streaming performance.

    Load Balancing: CDNs balance traffic load across multiple servers to handle concurrent requests efficiently, especially during peak viewing times.

    Just-in-time encoding with FastPix

    Just-In-Time (JIT) encoding makes video streaming better by encoding videos right when needed, saving storage space, and ensuring smooth playback on any device. This approach cuts costs, can handles high demand  and delivers high-quality video by adapting to different devices and network conditions.  At FastPix we are committed to make video simpler and a create  better experience for the viewers.

    Enjoyed reading? You might also like

    Try FastPix today!

    FastPix grows with you – from startups to growth stage and beyond.