Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
a Summer night - @971.24
Activity rating: Four Stars Posts & Arts: 53/1k.beats Random | Recent Posts | Guild Recents
News: Love is not possession  :4u: Guild Events: Summerween Watch-a-thon

+  MelonLand Forum
|-+  Life & The Web
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ I need Help!
| | | |-+  how to extract artist name metadata from mp4 stream?


« previous next »
Pages: [1] Print Embed
Author Topic: how to extract artist name metadata from mp4 stream?  (Read 1326 times)
candycanearter07
Hero Member ⚓︎
*****
View Profile WWWArt


i like slimes
⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games
RSS: RSS

Guild Memberships:
Artifacts:
Visited on Melon's 10th Anniversary!it's tbhchansey!Goomy, I Choose You!uh oh! a pigeon got in!Artsy Candy Cane
« on: a Summer night » Embed

hi,

how would i go about extracting the artist name metadata from an mp4 stream in a sane way without using an npm package?

edit: after a lot more investigation it looks like i have to parse ICY metadata from the stream somehow
edit2: also i need to figure out either another chiptune internet radio station or how to make it accept a http stream

« Last Edit: a Summer night by candycanearter07 » Logged

new to oldnet be nice
https://status.cafe/users/candycanearter/badge.png https://abslimeware.neocities.org/assets/images/blinkers/penguins.gif

https://abslimeware.neocities.org/assets/images/blinkers/slimebounce.gif https://card.exophase.com/2/0/268504.png?1727352149

https://i.imgur.com/S1cx8ZZ.pnghttps://i.imgur.com/7ntZZGM.pnghttps://i.imgur.com/xKIpW2A.pnghttps://i.imgur.com/YMPbu9R.png

Artifact Swap: buzzystickerSave the saveshoeBlob Creaturecards all the way downCommon Slorg
Melooon
Hero Member ⚓︎
*****
View Profile WWWArt


So many stars!
⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: melon
iMood: Melonking
Itch.io: My Games
RSS: RSS

Guild Memberships:
Artifacts:
You're a Star!I got robbed by Dan Q on Melonland!Flinstone VitaminAlways working hard!Known Apple shillcoolest melon on the web!
« Reply #1 on: a Summer day » Embed

This is a super cool question and I'd love to know more about it! I hope you'll share your code and findings when you figure it out  :ozwomp:

Logged


everything lost will be recovered, when you drift into the arms of the undiscovered

Artifact Swap: Visited on Melon's 10th Anniversary!Wildflowers!bitsy catRed TulipMellohiI met Dan Q on Melonland!?Flowers
candycanearter07
Hero Member ⚓︎
*****
View Profile WWWArt


i like slimes
⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games
RSS: RSS

Guild Memberships:
Artifacts:
Visited on Melon's 10th Anniversary!it's tbhchansey!Goomy, I Choose You!uh oh! a pigeon got in!Artsy Candy Cane
« Reply #2 on: a Summer night » Embed

WAIT OMG I ACTUALLY DID IT!!

Apparently, the metadata is just stored as ASCII inside the stream, so literally I just set up a loop to continuously retrieve data from the server, regex it for "StreamTitle", then saved that to a string!!

Note: IDK if it's just the server I'm using, but it does seem to only send the StreamTitle tag when you first connect and when the song changes, so you will have to be careful with that. Also, it seems to always output a StreamTitle of <empty string> when you first connect, tho that gets updated in a few seconds.

Also, this doesn't actually play the stream, you'll have to get a seperate <audio> tag to do that. I could probably figure out how to stream the data to an audio tag manually, but that would be infinitely harder.

code:
Code
async function readConstant(readableStream) {
  const reader = readableStream.getReader();
  const re = /StreamTitle='(.*)'/;

  while (true) {
    const { done, value } = await reader.read();
    if (done) { break; }

    // data is retrieved as a uint8 array, which we convert to str
    let cur = new TextDecoder("utf-8").decode(value);
    var fin = re.exec(cur);
    if (!fin) { continue; }

    // for some reason, the regex sometimes captures some unprintable chars after the end so we split on the single quote
    fin = fin[1].split('\'')[0];
    console.log(fin);
    document.getElementById("player-text").innerHTML = fin;
  }
}

var opts = { headers: {} };
opts["headers"]["Icy-MetaData"] = "1";
// this is the 64kbps version to save some bandwidth
let mustr = fetch("https://radio.erb.pw/listen/subspace/radio-64.mp3", opts);
mustr.then((res) => { readConstant(res.body) });

Logged

new to oldnet be nice
https://status.cafe/users/candycanearter/badge.png https://abslimeware.neocities.org/assets/images/blinkers/penguins.gif

https://abslimeware.neocities.org/assets/images/blinkers/slimebounce.gif https://card.exophase.com/2/0/268504.png?1727352149

https://i.imgur.com/S1cx8ZZ.pnghttps://i.imgur.com/7ntZZGM.pnghttps://i.imgur.com/xKIpW2A.pnghttps://i.imgur.com/YMPbu9R.png

Artifact Swap: buzzystickerSave the saveshoeBlob Creaturecards all the way downCommon Slorg
candycanearter07
Hero Member ⚓︎
*****
View Profile WWWArt


i like slimes
⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games
RSS: RSS

Guild Memberships:
Artifacts:
Visited on Melon's 10th Anniversary!it's tbhchansey!Goomy, I Choose You!uh oh! a pigeon got in!Artsy Candy Cane
« Reply #3 on: a Summer night » Embed

ironically now im having issues with actually playing the dang thing?? it keeps saying my function isnt defined :(

Code
<div id="player">
    <span id="player-text"></span>
    <a onclick="stopEr();" href="javascript:void(0)">stop</a>
    <a onclick="playEr();" href="javascript:void(0)">play</a>
</div>

<audio id="interadio" src="https://radio.erb.pw/listen/subspace/radio.mp3"></audio>
<script src='/assets/js/icystream.js'></script>

<script>
    var player = document.getElementById('interadio');
    var playertxt = document.getElementById('player-text');

    function playEr(){
        player.play();
        playertxt.style.display = 'inline':
    };

    function stopEr(){
        player.stop();
        playertxt.style.display = 'none';
    };
</script>
anyone know why its not working??

edit: im an idiot and colon is too similar to semicolon

« Last Edit: a Summer night by candycanearter07 » Logged

new to oldnet be nice
https://status.cafe/users/candycanearter/badge.png https://abslimeware.neocities.org/assets/images/blinkers/penguins.gif

https://abslimeware.neocities.org/assets/images/blinkers/slimebounce.gif https://card.exophase.com/2/0/268504.png?1727352149

https://i.imgur.com/S1cx8ZZ.pnghttps://i.imgur.com/7ntZZGM.pnghttps://i.imgur.com/xKIpW2A.pnghttps://i.imgur.com/YMPbu9R.png

Artifact Swap: buzzystickerSave the saveshoeBlob Creaturecards all the way downCommon Slorg
candycanearter07
Hero Member ⚓︎
*****
View Profile WWWArt


i like slimes
⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games
RSS: RSS

Guild Memberships:
Artifacts:
Visited on Melon's 10th Anniversary!it's tbhchansey!Goomy, I Choose You!uh oh! a pigeon got in!Artsy Candy Cane
« Reply #4 on: a Summer night » Embed

OK so ICY-Metadata is a type of metadata used to communicate the song name within an Icecast stream. Icecast streams are a type of internet streaming that only communicates an mp3 file, and is the most common way that internet radio streams are broadcasted. This type of metadata is commnicated with the TAGS element of mp3 files, being a string of ascii text embeded within the data. It can easily be extracted by matching against regex /StreamTitle:'(.*)';/ (using the javascript syntax). This data can be used to display the currently playing song when playing a internet radio stream.

Logged

new to oldnet be nice
https://status.cafe/users/candycanearter/badge.png https://abslimeware.neocities.org/assets/images/blinkers/penguins.gif

https://abslimeware.neocities.org/assets/images/blinkers/slimebounce.gif https://card.exophase.com/2/0/268504.png?1727352149

https://i.imgur.com/S1cx8ZZ.pnghttps://i.imgur.com/7ntZZGM.pnghttps://i.imgur.com/xKIpW2A.pnghttps://i.imgur.com/YMPbu9R.png

Artifact Swap: buzzystickerSave the saveshoeBlob Creaturecards all the way downCommon Slorg
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
MelonLand @000

Want to Login or Join ?

Minecraft: Online
Join: craft.melonking.net