Borewit/music-metadata

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

Opened this issue · 2 comments

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.

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.

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.