samrocketman / sounds-of-endless-sky

GNU General Public License v3.0
6 stars 1 forks source link

Embed media metadata #3

Open tibetiroka opened 1 year ago

tibetiroka commented 1 year ago

It would be great to have some metadata information embedded in the mp3 file, such as the artist name and the song's title. This can be done with ID3, for example. Ffmpeg supports this format (it uses ID3v2.4 by default), or other tools like the id3v2 command line utility, which usually has better compatibility (although they both claim to do the exact same thing).

Since you have both the track names and the artists' names and re-encode the whole file, this seems like the optimal place to do this automatically.

(Of course, with the music PR, I don't know if this repo will even be maintained in the future. Maybe this is something we should consider for music that's added to the game, too.)

samrocketman commented 1 year ago

You can see in the README how I encoded the music with specific settings. How would I change the command to support what you're asking? The raw repository is the source of the music so we can make changes there and re-encode.

There was a lot of trial and error to get the encoded mp3 to work with ES. ES will refuse to play without particular playback bit rates.

tibetiroka commented 1 year ago

Based on this: https://unix.stackexchange.com/questions/60302/how-to-set-metadata-for-music-files

You can modify the ffmpeg command like to include these options: -metadata artist=[...] -metadata title=[...]. You can get the artist's name from the name of the directory containing the file, and the title is the filename without the extension. Should be a pretty simple batch script.

You can do the same with id3v2, as a separate command after the unchanged ffmpeg command. This command edits mp3 files in-place. id3v2 -2 --artist [...] --song [...] [filename]

This doesn't affect the bitrate or any other property of the mp3 file.

samrocketman commented 1 year ago

I'll take a look at how to do this. It likely warrants creating a script to automate music encoding. Thanks for the info.