Skip to content

Optionally yield metadata before first frame (feature request) #25

@HDegroote

Description

@HDegroote

Context: I'm using this library to split a FLAC file into frames, but I also need the metadata (all bytes before the first frame).

From what I understand, the current code simply drops all bytes before the first frame. Would you be open to adding an option which, if set, yields all those bytes as the first chunk?

By accessing the library internals, I can use this workaround:

    const parser = new CodecParser('audio/flac')
    let nrMetadataBytes = null
    
    for await (const entry of stream) {
      for (const frame of parser.parseChunk(entry)) {
        if (nrMetadataBytes === null) { // First frame
          nrMetadataBytes = parser._currentReadPosition - frame.data.length
        }
        // ... process the normal frames
    }

But it's pretty ugly and inconvenient (I have to open a new readStream to actually read those bytes since they're already skipped)

Willing to create a PR if you're open to adding this (feel free to close if not)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions