Media Prepare

Presets

Pre-configured bitrate ladders for common use cases

The library includes pre-configured bitrate ladders for common streaming scenarios.

Built-in Presets

vodHd_1080p

A 3-rung HD ladder suitable for most web streaming:

import { videoLadderPresets } from "@shelby-protocol/media-prepare/core";

builder.withVideoLadder(videoLadderPresets.vodHd_1080p);
RungResolutionBitrate
1080p1920x10805 Mbps
720p1280x7203 Mbps
480p854x4801.2 Mbps

Preset Constants

The library exports strongly typed resolution groups to help build ladders:

Standard Resolutions

import {
  SD_RESOLUTIONS,
  HD_RESOLUTIONS,
  FULL_HD_RESOLUTIONS,
  RESOLUTION_4K,
} from "@shelby-protocol/media-prepare/core";

SD_RESOLUTIONS.SD_480P_16_9;  // 854x480
HD_RESOLUTIONS.HD_720P_16_9;  // 1280x720
FULL_HD_RESOLUTIONS.FHD_1080P_16_9; // 1920x1080
RESOLUTION_4K.UHD_4K_16_9;    // 3840x2160

Streaming Ladders

import { RESOLUTION_PRESETS } from "@shelby-protocol/media-prepare/core";

RESOLUTION_PRESETS.WEB_STREAMING;     // HD -> 2K
RESOLUTION_PRESETS.MOBILE_STREAMING;  // SD -> Full HD
RESOLUTION_PRESETS.PREMIUM_STREAMING; // Full HD -> 4K
RESOLUTION_PRESETS.CINEMA_STREAMING;  // Ultra-wide ladder

Custom Ladders

Build custom ladders for specific requirements:

const customLadder = [
  { width: 3840, height: 2160, bitrateBps: 15_000_000, name: "4K" },
  { width: 1920, height: 1080, bitrateBps: 6_000_000, name: "1080p" },
  { width: 1280, height: 720, bitrateBps: 3_000_000, name: "720p" },
  { width: 854, height: 480, bitrateBps: 1_500_000, name: "480p" },
  { width: 640, height: 360, bitrateBps: 800_000, name: "360p" },
];

builder.withVideoLadder(customLadder);

Ladder Design Guidelines

Bitrate Ratios

For smooth quality transitions, use ~2x bitrate jumps between rungs:

QualityTypical Bitrate
4K (2160p)12-20 Mbps
1080p4-8 Mbps
720p2-4 Mbps
480p1-2 Mbps
360p0.5-1 Mbps

Mobile Considerations

For mobile-first streaming, include lower rungs:

const mobileLadder = [
  { width: 1280, height: 720, bitrateBps: 2_500_000, name: "720p" },
  { width: 854, height: 480, bitrateBps: 1_200_000, name: "480p" },
  { width: 640, height: 360, bitrateBps: 600_000, name: "360p" },
  { width: 426, height: 240, bitrateBps: 300_000, name: "240p" },
];

Bandwidth Constraints

For Shelby blob storage, consider segment size limits when choosing bitrates. Higher bitrates produce larger segments:

Segment Size ≈ (Bitrate × Segment Duration) / 8

Example: 5 Mbps × 4 seconds = 2.5 MB per segment

Use withComputedSegmentDuration() to automatically calculate optimal segment duration based on your blob size constraints and bitrate ladder.