Closed mateusz-uzz closed 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);
})();
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)?
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.
As this is done outside the audio stream, music-metadata is not the suitable component to implement this.
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:
At the same time an application like foobar2000 is able to get the artist and song title from the stream as you can see:
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