Skip to content
Docs/SSAI/Container Formats

Container Formats: TS & CMAF

ApexMediation SSAI supports both MPEG Transport Stream (TS) and Common Media Application Format (CMAF/fMP4) containers for maximum device compatibility.

Container Comparison

The ContainerHandler manages both formats with correct MIME types and file conventions per HLS/DASH specifications.

AspectTS (.ts)CMAF (.m4s)
Full NameMPEG Transport StreamCommon Media Application Format
Extensions.ts, .m2ts, .mts.m4s, .mp4, .m4a, .m4v
Video MIMEvideo/MP2Tvideo/mp4
Audio MIMEaudio/MP2Taudio/mp4
Init SegmentNot required (self-contained)Required (separate .mp4/.m4s)
HLS Support✓ Full✓ Full (HLS v6+)
DASH Support△ Limited✓ Full

MPEG Transport Stream (TS)

Transport Stream is the legacy container format, widely supported across all devices. Each segment is self-contained with headers.

Advantages

  • Universal device compatibility
  • Self-contained segments (no init needed)
  • Simple error recovery (each segment independent)
  • Legacy encoder support

Disadvantages

  • ~15% overhead per segment (repeated headers)
  • Limited DASH support (requires player-specific config)
  • No native browser support (requires hls.js)
  • Limited DRM options

TS Detection

From ContainerHandler.detectContainerType():

// Extensions recognized as TS
private static readonly TS_EXTENSIONS = ['.ts', '.m2ts', '.mts'];

// MIME types
private static readonly MIME_TYPES = {
  ts: {
    video: 'video/MP2T',
    audio: 'audio/MP2T',
  },
  // ...
};

Common Media Application Format (CMAF)

CMAF (also known as fMP4 - fragmented MP4) is the modern container format designed for efficient streaming. It's the preferred format for new deployments.

Advantages

  • Lower overhead (shared init segment)
  • Full HLS + DASH support
  • Native browser support (MSE)
  • Full DRM support (Widevine, FairPlay, PlayReady)
  • Low-latency streaming capable

Considerations

  • Init segment required before media segments
  • Init segment must match at discontinuities
  • Older devices may lack support

CMAF Detection & Init Segments

// Extensions recognized as CMAF
private static readonly CMAF_EXTENSIONS = ['.m4s', '.mp4', '.m4a', '.m4v'];

// MIME types
private static readonly MIME_TYPES = {
  cmaf: {
    video: 'video/mp4',
    audio: 'audio/mp4',
    init: 'video/mp4',
  },
  // ...
};

// HLS playlist with init segment
#EXT-X-MAP:URI="init.mp4"
#EXTINF:6.000,
segment1.m4s
#EXTINF:6.000,
segment2.m4s

SSAI Container Requirements

When stitching ads into content, the container format must match between content and ads to ensure seamless playback.

Format Matching

HLS/TS content requires HLS/TS ads. DASH/CMAF content requires DASH/CMAF ads. The pod decisioning engine filters ads by container format compatibility.

Init Segment Handling (CMAF)

At content-to-ad transitions, the SSAI stitcher inserts the ad init segment via #EXT-X-MAP or DASH Initialization. At ad-to-content transitions, the content init segment is restored.

Codec Consistency

Beyond container format, codecs must be compatible. The system validates codec strings (H.264: avc1.*, H.265: hvc1.*, AAC: mp4a.40.*) between content and ads.

Codec Patterns

// From ContainerHandler
private static readonly CODEC_PATTERNS = {
  h264: /avc[1-4]\.[0-9A-Fa-f]+/,      // H.264/AVC
  h265: /hvc1\.[0-9A-Za-z.]+|hev1\.[0-9A-Za-z.]+/, // H.265/HEVC
  aac: /mp4a\.40\.[0-9]+/,             // AAC
  ac3: /ac-3/,                          // Dolby Digital
  eac3: /ec-3/,                         // Dolby Digital Plus
};

Protocol/Container Matrix

ProtocolContainerLiveVODPlayers
HLSTSAVPlayer, hls.js, ExoPlayer
HLSCMAFAVPlayer, hls.js, ExoPlayer, Shaka
DASHTSLimited ExoPlayer support
DASHCMAFShaka, dash.js, ExoPlayer

Recommendations

For New Deployments

Use CMAF/fMP4 as your primary container. It provides the best efficiency, DRM support, and works with both HLS and DASH protocols.

For Maximum Compatibility

Offer both HLS/TS and HLS/CMAF. Let the SDK select based on device capabilities. This covers legacy and modern devices.

For CTV Focus

CTV devices (Apple TV, Roku, Fire TV, Android TV) all support CMAF. Use HLS/CMAF for Apple TV (AVPlayer) and DASH/CMAFfor Android TV (ExoPlayer).

Related Documentation