Skip to main content

Module codec_strings

Module codec_strings 

Source
Expand description

HLS / DASH CODECS attribute string generation.

Generates the precise codec-string bytes that go into the #EXT-X-STREAM-INF:CODECS="..." line of a HLS master playlist. These strings are what hls.js (and Safari’s native HLS, and DASH players) use to decide whether the browser can play a given variant BEFORE downloading any media bytes. A wrong string causes the variant to be silently skipped, so they have to be parsed from the actual bitstream — never composed from a config file.

Sources of truth:

  • AV1: AV1 Codec ISO Media File Format Binding v1.2.0 §A.3, “Codecs Parameter String”
  • AAC-LC in MP4: ISO/IEC 14496-3 + RFC 6381 §3.3
  • AVC: RFC 6381 §3.3 (avc1.PPCCLL hex from SPS)
  • HEVC: ISO/IEC 14496-15 §A.5

Emits AV1, H.264 (avc1/avc3), H.265 (hvc1/hev1), and AAC strings.

Constants§

AAC_LC_CODEC_STRING
AAC-LC in MP4 codec string. Always mp4a.40.2:

Functions§

av1_codec_string
AV1 codec string — av01.P.LLT.DD.M.CCC.TTT.MMM.F.
avc_codec_string
H.264 codec string <fourcc>.PPCCLL per RFC 6381 §3.3 — hex bytes from the SPS: PP = profile_idc, CC = the packed constraint_set flags byte, LL = level_idc. fourcc is the sample-entry type: avc1 (parameter sets out-of-band in avcC) or avc3 (in-band). Example: High@L4.0 → avc1.640028.
hevc_codec_string
H.265 codec string <fourcc>.{space}{profile}.{compat}.{tier}{level}{.cons}* per ISO/IEC 14496-15 §E.3, parsed from the SPS profile_tier_level:
hls_codecs_attribute
Convenience: pack an HLS CODECS= attribute value for a variant that carries one video and one audio track. Order is <video>,<audio> per RFC 8216 §4.3.4.2 and HLS-Authoring spec.