Home Events! Entrance Everyone Wiki Search Login Register

Welcome, Guest. Please login or register. - Thinking of joining the forum??
November 21, 2024 - @590.51 (what is this?)
Forum activity rating: Three Stars Posts: 38/1k.beats Unread Topics | Unread Replies | My Stuff | Random Topic | Recent Posts    Start New Topic
News: :ha: :pc: Hello Melonland! :pc: :happy:

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


« previous next »
Pages: [1] Print
Author Topic: how to extract artist name metadata from mp4 stream?  (Read 247 times)
candycanearter07
Sr. Member ⚓︎
****


i like slimes

⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games

View Profile WWW

Suck At Something September - Did It!uh oh! a pigeon got in!Artsy Candy CaneJoined 2024!
« on: August 10, 2024 @176.01 »

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: August 10, 2024 @207.99 by candycanearter07 » Logged

new to oldnet be nice




Melooon
Hero Member ⚓︎
*****


So many stars!

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

View Profile WWW

Thanks for being rad!a puppy for your travelsAlways My PalFirst 1000 Members!spring 2023!Squirtle!!!!MIDI WarriorMIDI Warrior1234 Posts!OzspeckCool Dude AwardRising Star of the Web AwardMessage BuddyPocket Icelogist!OG! Joined 2021!...
« Reply #1 on: August 10, 2024 @576.37 »

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
candycanearter07
Sr. Member ⚓︎
****


i like slimes

⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games

View Profile WWW

Suck At Something September - Did It!uh oh! a pigeon got in!Artsy Candy CaneJoined 2024!
« Reply #2 on: August 11, 2024 @127.23 »

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




candycanearter07
Sr. Member ⚓︎
****


i like slimes

⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games

View Profile WWW

Suck At Something September - Did It!uh oh! a pigeon got in!Artsy Candy CaneJoined 2024!
« Reply #3 on: August 11, 2024 @166.41 »

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: August 11, 2024 @175.64 by candycanearter07 » Logged

new to oldnet be nice




candycanearter07
Sr. Member ⚓︎
****


i like slimes

⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games

View Profile WWW

Suck At Something September - Did It!uh oh! a pigeon got in!Artsy Candy CaneJoined 2024!
« Reply #4 on: August 12, 2024 @958.76 »

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




Pages: [1] Print 
« previous next »
 

Vaguely similar topics! (3)

sleepyXTRA - Inside The Mind of The Lo-Fi Artist - released FREE!

Started by ellievoyydBoard © ∙ Music Room

Replies: 1
Views: 1664
Last post September 28, 2024 @297.34
by evelly
Artist + Programmer up for collaboration

Started by NecrosiaBoard ✎ ∙ Art Crafting

Replies: 19
Views: 1970
Last post March 26, 2023 @898.31
by SilkSkull
FromSoftware / Soulsborne Games

Started by sigBoard ♖ ∙ Video Games

Replies: 5
Views: 954
Last post March 09, 2023 @990.24
by Memory

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021, Simple Machines | Terms and Policies 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