Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: "Invalid FLAC preamble" for streams in FLAC format #2034

Open
bojanvidanovic opened this issue Apr 4, 2024 · 2 comments
Open

Error: "Invalid FLAC preamble" for streams in FLAC format #2034

bojanvidanovic opened this issue Apr 4, 2024 · 2 comments

Comments

@bojanvidanovic
Copy link

bojanvidanovic commented Apr 4, 2024

Hi,
I'm getting an error Error: Invalid FLAC preamble when I try to get metadata from a stream in FLAC format.

Here is what I did:

const metadata = await musicMetadata.parseReadableStream(http://stream.radioparadise.com/global-flac, {
   mimeType: 'audio/flac',
});

It works fine with other formats except for FLAC, and I think you can probably reproduce it with the above configuration.
Tested with the latest Chrome and Firefox.

Let me know if you need any more details.
Thanks.

@bojanvidanovic bojanvidanovic changed the title Error: gg audio-codec not recognized (id= FLAC ) Error: Invalid FLAC preamble for streams in FLAC format Apr 17, 2024
@bojanvidanovic
Copy link
Author

I have updated the issue because I was not explicitly setting the mime type, instead I was relying on automatic detection which would set the OGG parser for FLAC and fail.
Now with the mime type and correct parser, the issue arises here.

@bojanvidanovic bojanvidanovic changed the title Error: Invalid FLAC preamble for streams in FLAC format Error: "Invalid FLAC preamble" for streams in FLAC format Apr 17, 2024
@Borewit Borewit transferred this issue from Borewit/music-metadata-browser Apr 24, 2024
@Borewit
Copy link
Owner

Borewit commented Apr 24, 2024

Interesting problem @bojanvidanovic.

The MIME type is application/ogg and actually suspect that is the correct MIME type. So the stream is no audio/flac.
So you should provide the original HTTP MIME type to music-metadata.

But I won't work.

What I suspect is that the stream is not formatted like a FLAC file, but it is an Ogg stream carrying FLAC.

And the Ogg/FLAC combination is not implemented.

I created branch which will throw a more specific error:

throw new Error('Crap, we don\'t have a page consumer for Ogg/FLAC yet.');

Which can be triggered with

it('Stream Ogg/FLAC from radioparadise.com', async () => {
const url = 'http://stream.radioparadise.com/global-flac';
const response = await clients[0].client.get(url);
const fileInfo: IFileInfo = {
mimeType: response.headers['content-type']
};
const tags = await parseStream(response.stream, fileInfo);
if (response.stream.destroy) {
response.stream.destroy(); // Node >= v8 only
}
assert.strictEqual(tags.format.container, 'Ogg/FLAC');
});

Sorry, I do not have a lot time lately.

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

No branches or pull requests

2 participants