taglib-ts
    Preparing search index...

    Parser for a single MPEG audio frame header (4 bytes).

    When checkLength is true the parser also verifies that a second valid frame header with matching version / layer / sample-rate exists at the expected position (offset + frameLength).

    Index

    Accessors

    • get channels(): number

      Gets the number of audio channels (1 for mono, 2 for all stereo modes).

      Returns number

    • get frameLength(): number

      Gets the total byte length of this frame (header + payload).

      Returns number

    • get isADTS(): boolean

      Gets whether this is an ADTS (AAC) frame rather than a standard MPEG frame.

      Returns boolean

    • get isCopyrighted(): boolean

      Gets whether the audio is flagged as copyrighted.

      Returns boolean

    • get isOriginal(): boolean

      Gets whether the audio is flagged as an original recording.

      Returns boolean

    • get isPadded(): boolean

      Gets whether this frame includes a padding slot.

      Returns boolean

    • get isValid(): boolean

      Gets whether the header represents a valid MPEG audio frame.

      Returns boolean

    • get layer(): number

      Gets the MPEG layer (1, 2, or 3); 0 for ADTS.

      Returns number

    • get protectionEnabled(): boolean

      Gets whether CRC protection is enabled for this frame.

      Returns boolean

    • get samplesPerFrame(): number

      Gets the number of PCM samples encoded in this frame.

      Returns number

    Methods

    • Reads and parses an MPEG frame header from the stream at the given offset.

      Parameters

      • stream: IOStream

        The I/O stream to read from.

      • offset: number

        Byte offset within the stream at which the frame header starts.

      • checkLength: boolean = false

        When true, the next frame is also validated to confirm this is real audio.

      Returns Promise<MpegHeader>

      A fully parsed MpegHeader; check isValid before using the result.