Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Live stream format with proper metadata & embededd album covers (Read 1430 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Live stream format with proper metadata & embededd album covers

I have been investigating the subject of streaming audio, from one device to another, with live track metadata and covers displayed on remote end. Similar to what many internet radio streams do, but I hope to achieve full pass-through of information such as multiple artists, album name, genre, album cover picture, etc.

Options looked into so far:
  • MP3, AAC with icy-metadata
    Very limited metadata capabilities, there does not appear to be any official specification of the icy-metadata protocol despite being in mainstream use for over 20 years. No metadata beyond artist - title, no proper delimiting of these two, unspecified character encoding (though everyone seems to have finally agreed to send UTF-8 by now). Some radio stations even transmit album cover picture links.
  • Ogg Vorbis
    Historically the first format to get of this stuff right, by sending new Vorbis stream headers with each new song. Sadly seems to be dying out.
  • Opus
    Technically possible to send live info as with Vorbis, but nobody seems to do actually it?
  • FLAC
    Live metadata capability missing, libFLAC won't decode concatenated FLAC files with new metadata.
  • Ogg FLAC
    Live metadata capability missing, libFLAC won't decode concatenated Ogg FLAC files with new metadata.
    EDIT: libFLAC 1.5.0 can decode chained Ogg streams, this looks like the most promising option so far.
    Certain radio station uses Ogg FLAC with icy-metadata, which is a horrible idea but works.

Any better ideas, preferably with lossless audio?
I'm trying to do this without inventing own formats, so other players can play this out of the box or with minimal changes.
Is there anything that has any remote chance of being recognized by standalone UPnP players?
Microsoft Windows: We can't script here, this is bat country.

Re: Live stream format with proper metadata & embededd album covers

Reply #1
Could the Matroska container be used or does the intended container need to be a "normal" audio format in this context?

 

Re: Live stream format with proper metadata & embededd album covers

Reply #2
Matroska looks like it could work: infinite-length stream supported, Tags element between Cluster elements would indicate new live metadata, though not sure if it's really allowed by the specification that Tags element applies to content from this point on.
Know any examples of such already in circulation?

Unfortunately Matroska support isn't that common among audio players, hardware or software, getting others to support it might be hard.
Microsoft Windows: We can't script here, this is bat country.

Re: Live stream format with proper metadata & embededd album covers

Reply #3
ogg flac, ogg with contain encode flac inside data

Re: Live stream format with proper metadata & embededd album covers

Reply #4
Know any examples of such already in circulation?
I don't, no, sorry - the container came to mind as it's open source and I've encountered it with video and audio in it where the album cover could be a single frame video file while the music could be the associated audio track, and it allows tags.

Re: Live stream format with proper metadata & embededd album covers

Reply #5
Ogg FLAC
Live metadata capability missing, libFLAC won't decode concatenated Ogg FLAC files with new metadata.
Actually, this functionality has been added with FLAC 1.5.0. Along with multithreading, this was the other major new feature.
Music: sounds arranged such that they construct feelings.

Re: Live stream format with proper metadata & embededd album covers

Reply #6
Ogg FLAC
Live metadata capability missing, libFLAC won't decode concatenated Ogg FLAC files with new metadata.
Actually, this functionality has been added with FLAC 1.5.0. Along with multithreading, this was the other major new feature.
Thanks, verified working with new methods, updated original post.
Ogg FLAC looks like the most promising option so far.
Microsoft Windows: We can't script here, this is bat country.

Re: Live stream format with proper metadata & embededd album covers

Reply #7
For now it would be a good quick-win when the non playing TF field %title% (which has the stream name) would also be available in a TF field while playing (%stream name% perhaps?).

EDIT: Sorry, did not see this is not a foobar forum/thread.

Re: Live stream format with proper metadata & embededd album covers

Reply #8
Actually, this functionality has been added with FLAC 1.5.0. Along with multithreading, this was the other major new feature.
I didn't know this either, and I found rich set of new APIs in FLAC/stream_decoder.h for chained ogg stream.

Just one thing...

Can you add FLAC_free() or something in favor of Windows ?
In Windows, apps and DLLs can be linked to different C runtime libraries. In such cases, If a DLL allocates memory with malloc() and an  app attempts to free that memory by free(), bad things can happen (usually SEGV).

FLAC__stream_decoder_get_link_lengths() requires exactly this, which is problematic.
To avoid this issue, DLL can simply export a wrapper of free() function of the C runtime library to which DLL is linked.

Re: Live stream format with proper metadata & embededd album covers

Reply #9
Can you add FLAC_free() or something in favor of Windows ?
In Windows, apps and DLLs can be linked to different C runtime libraries. In such cases, If a DLL allocates memory with malloc() and an  app attempts to free that memory by free(), bad things can happen (usually SEGV).
Ah, that is a bummer. I wasn't aware this could be necessary. Do you know of another project with such a wrapper, so I can take a look whether there are any additional caveats?

Also, if you have suggestions for improvements, please let me know. This addition has seen little review, and I'm unsure whether the current set of functions is enough to be implemented easily, or whether more functions are necessary.
Music: sounds arranged such that they construct feelings.

Re: Live stream format with proper metadata & embededd album covers

Reply #10
Ah, that is a bummer. I wasn't aware this could be necessary. Do you know of another project with such a wrapper, so I can take a look whether there are any additional caveats?
ffmpeg has av_ prefixed memory related functions in libavutil (mem.c).
These kinds of functions, such as Python's PyMem_* functions, often use special allocators rather than being mere wrappers around malloc()/free(). However, in the case of ffmpeg, they are simply wrappers.

Re: Live stream format with proper metadata & embededd album covers

Reply #11
I've wrote some 100 lines of code that scans chained ogg-flac file with libFLAC 1.5.
https://gist.github.com/nu774/d82ffd0b0c637b34fb3369cdc779e1cb
This basically read metadata of each link and skip to the next until it reaches the end of file.
It's reasonably easy, but I want a way to jump/seek to arbitrary link after that.
After the whole scanning process done, I believe all link positions in file are internally indexed, but I don't know what is the appropriate way.
Do I have to use FLAC__stream_decoder_seek_absolute()? Or just repeatedly call FLAC__stream_decoder_skip_single_link()?

Re: Live stream format with proper metadata & embededd album covers

Reply #12
seek_absolute would be fastest, it'll seek directly to the right link. It will also return metadata if the seek crosses a link boundary. If you don't want that, you can use FLAC__stream_decoder_set_metadata_ignore_all before seeking.
Music: sounds arranged such that they construct feelings.

Re: Live stream format with proper metadata & embededd album covers

Reply #13
OK, Thanks.

BTW, I found that oggenc's default serial number generation is not random enough, and quite easily collide.
As far as I can see, oggenc, flac, and opusenc use different methods for seeding random generator.
oggenc just uses getpid() ^ time(NULL) as random seed, which might be too weak to be used as entropy...

Re: Live stream format with proper metadata & embededd album covers

Reply #14

Options looked into so far:
  • MP3, AAC with icy-metadata
    Very limited metadata capabilities, there does not appear to be any official specification of the icy-metadata protocol despite being in mainstream use for over 20 years. No metadata beyond artist - title, no proper delimiting of these two, unspecified character encoding (though everyone seems to have finally agreed to send UTF-8 by now). Some radio stations even transmit album cover picture links.
  • Ogg Vorbis
    Historically the first format to get of this stuff right, by sending new Vorbis stream headers with each new song. Sadly seems to be dying out.
  • Opus
    Technically possible to send live info as with Vorbis, but nobody seems to do actually it?
  • FLAC
    Live metadata capability missing, libFLAC won't decode concatenated FLAC files with new metadata.
  • Ogg FLAC
    Live metadata capability missing, libFLAC won't decode concatenated Ogg FLAC files with new metadata.
    EDIT: libFLAC 1.5.0 can decode chained Ogg streams, this looks like the most promising option so far.
    Certain radio station uses Ogg FLAC with icy-metadata, which is a horrible idea but works.



Below is my test icecast broadcast server , using a combination of foobar2000, virtual cable, liquidsoap and icecast.

http://zeremy.serv00.net:8200/status.xsl

Both opus and flac streams are chained, have metadata and include a cover_url tag witha link of the artwork for remote downloading  by the client.

I use a Jscript3 panel in foobar2000 to grab either $info(cover_url) or %cover_url% link to display the artwork.

The problem is that most clients don't support chained ogg, foobar2000 and aimp though work fine.

Relative discussions I had
https://github.com/savonet/liquidsoap/discussions/3990
https://github.com/AzuraCast/AzuraCast/issues/7240

If wanted I could provide more details of the setup.