ISOMedia.Codec (ISOMedia v0.2.0)

Copy Markdown View Source

Read-only extraction of a track's codec + media metadata into %ISOMedia.TrackInfo{}. Slices the opaque stsd sample entry and mdhd tail directly (avc1 + mp4a); the core parser/Registry are untouched, so the byte-for-byte round-trip invariant is preserved.

Summary

Functions

Build an avc1.PPCCLL codec string from an avcC payload.

Decode an MPEG-4 expandable length (each byte's high bit is a continuation flag; the low 7 bits accumulate). Returns {length, remaining_binary}.

Decode a packed 16-bit mdhd language field (1 pad bit + 3×5-bit, each char - 0x60) into an ISO-639-2/T 3-letter code. Falls back to "und" if any character is not a-z.

Return the payload of the first child box of type within a byte slice of boxes.

Decode a trak's codec + media metadata into a %ISOMedia.TrackInfo{}.

Build an mp4a.<oti>.<aot> codec string from an esds payload (AAC-LC fallback).

Sample rate (Hz) from an esds AudioSpecificConfig, or fallback if unavailable.

Functions

avc1_codec(arg)

@spec avc1_codec(binary()) :: String.t()

Build an avc1.PPCCLL codec string from an avcC payload.

decode_expandable_length(binary, acc \\ 0)

@spec decode_expandable_length(binary(), non_neg_integer()) ::
  {non_neg_integer(), binary()}

Decode an MPEG-4 expandable length (each byte's high bit is a continuation flag; the low 7 bits accumulate). Returns {length, remaining_binary}.

decode_language(arg)

@spec decode_language(<<_::16>>) :: String.t()

Decode a packed 16-bit mdhd language field (1 pad bit + 3×5-bit, each char - 0x60) into an ISO-639-2/T 3-letter code. Falls back to "und" if any character is not a-z.

find_sub_box(arg1, target)

@spec find_sub_box(binary(), binary()) :: binary()

Return the payload of the first child box of type within a byte slice of boxes.

info(trak)

Decode a trak's codec + media metadata into a %ISOMedia.TrackInfo{}.

mp4a_codec(esds)

@spec mp4a_codec(binary()) :: String.t()

Build an mp4a.<oti>.<aot> codec string from an esds payload (AAC-LC fallback).

mp4a_sample_rate(esds, fallback)

@spec mp4a_sample_rate(binary(), pos_integer() | nil) :: pos_integer() | nil

Sample rate (Hz) from an esds AudioSpecificConfig, or fallback if unavailable.