Borewit / music-metadata-browser

Browser version of music-metadata parser Supporting a wide range of audio and tag formats.
MIT License
239 stars 21 forks source link

No title or artist metadata from URL streams #781

Closed mateusz-uzz closed 2 years ago

mateusz-uzz commented 2 years ago

I am trying to use this package in an angular application to read metadata about streaming radio stations using an URL, however it seems the library is not able to catch the title and artist data. I tried running both in my own Angular project and the demo here that you provided. By dragging the stream URL on the drop box, some metadata about bitrate etc. is extracted however there is no title or artist name as you can see here: image

At the same time an application like foobar2000 is able to get the artist and song title from the stream as you can see: image

Here are some example streams i used: https://stream.open.fm/3 https://listen6.myradio24.com/walcon

From what I understand it should be possible to gather this information using this package

Borewit commented 2 years ago

Parsing a live stream is a bit different then parsing a file. The first trick to keep it processing the stream us to use the duration flag.

Then subscribe to the observer event, to get updates on metadata changes. Yet it is not returning the metadata you are looking, I need to dig deeper to find out how exactly the metadata is encoded.

Example with music-metadata:

const musicMetadata = require('music-metadata');
const fetch = require('node-fetch');

const audioTrackUrl = 'https://stream.open.fm/3';

console.log(`Fetching audio from: ${audioTrackUrl}`);

(async () => {
  const response = await fetch(audioTrackUrl); // Read HTTP headers
  const contentType = response.headers.get('content-type'); // Extract the content-type
  const metadata = await musicMetadata.parseStream(response.body, {mimeType: contentType}, {duration: true, observer: event => {
      console.log(event.tag);
    }}); // Parse and read the remainder of the HTTP body
  console.log(metadata.common);
})();
mateusz-uzz commented 2 years ago

I found this node module radio-id3 which works with these kind of streams, maybe these tags are not encoded using the file extension standards but using the streaming software standards (like Icecast)?

Borewit commented 2 years ago

You are right, it is done outside the original audio content standard. It looks like the mechanism used to retrieve the metadata is ICY metadata.

Borewit commented 2 years ago

As this is done outside the audio stream, music-metadata is not the suitable component to implement this.