Skip to content

FLAC: Add appendOnly option for FlaxMuxer, fix FlacDemuxer reading it#325

Merged
Vanilagy merged 8 commits intoVanilagy:mainfrom
JonnyBurger:flac-appendonly
Mar 19, 2026
Merged

FLAC: Add appendOnly option for FlaxMuxer, fix FlacDemuxer reading it#325
Vanilagy merged 8 commits intoVanilagy:mainfrom
JonnyBurger:flac-appendonly

Conversation

@JonnyBurger
Copy link
Copy Markdown
Contributor

Sample file generated: sample-append-only.zip (rename extension to .flac, since GitHub does not support .flac file extension)

  • Implemented appendOnly option which writes minimumFrameSize = 16, maximumFrameSize = 65535, minimumBlockSize = 0, maximumBlockSize = 0. Spec allows setting 0 as unknown for block sizes, but not for frame sizes. But frame sizes are 16-bit (Spec: 8.2 Streaminfo)
  • Manual test: Created a test file, put it in media-analyzer.pro and played it in Chrome.
  • Added a test to flac.test.ts

This discovered that the demuxer does not handle maximumBlockSize = 0.
I fixed it as well, and added links to the spec to back up the reason for the values chosen.

Comment thread src/flac/flac-demuxer.ts
const slice = await this.reader.requestSliceRange(
startPos,
this.audioInfo.minimumFrameSize,
maximumHeaderLength,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small optimization I figured: here we just wanna read the header, so we need at least maximumHeaderSize bytes, which will be lower than this.audioInfo.minimumFrameSize most of the times.

@Vanilagy
Copy link
Copy Markdown
Owner

Very nice, thank you! Looks clean to me. Wasn't there an issue related to this feature? I can't for the life of me find it!!

@Vanilagy Vanilagy enabled auto-merge (squash) March 19, 2026 13:43
@Vanilagy Vanilagy merged commit 31d8633 into Vanilagy:main Mar 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants