Skip to content

Conversation

@acolombier
Copy link
Member

@acolombier acolombier commented Oct 13, 2024

Closes #9134

Implemented for MP3 and Wave and tested with both.

ffprobe example with MP3

$ ffprobe ../2024-10-13_20h38m19s.mp3 
ffprobe [...]
   [...]
[mp3 @ 0x556661ba7b80] Skipping 339 bytes of junk at 813.
Input #0, mp3, from '/home/antoine/Music/Mixxx/Recordings/2024-10-13_20h38m19s.mp3':
  Metadata:
    encoder         : LAME 64bits version 3.100 (http://lame.sf.net)
    title           : Foo
    artist          : Bar
    album           : Baz
    comment         : 00:00:00: Twenty One Pilots - The Craving (single version)
                    : 00:00:09: Carnage - Psy Or Die
                    : 00:00:19: bbno$ - it boy
                    : 00:00:38: Armin van Buuren feat. Trevor Guthrie - This Is What It Feels Like
                    : 00:00:47: Armin van Buuren - Larger Than Life
                    : 00:01:06: Freestylers - Cracks - Flux Pavilion Remix
  Duration: 00:01:17.14, start: 0.023021, bitrate: 128 kb/s
  Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : LAME3.100

Note on MP3

After a long day of learning MP3 spec, it would appears that our implementation was somewhat flawed. My understanding is that the Xing frame that contains various parameter about the MP3 frames is expect in the beginning of the file, however we currently overwrite the first frames with it, leading to data loss. Since a frame is < 100ms, this is not something you can easily hear.

Second point is, we currently only write IDv1 (automatically supported by lame) but this limits the comment to 30 bytes. In order to lift this limit (and reach the hard limit of 2**32), we need to write ID3v2, but those are expected as header (unlike ID3v1 which can be appended in the footer when flushing the file.

In an ideal world, we would want to shift the file content to fit the ID3 header + the Xing frame. Because this basically requires to tear down the whole EncoderCallback mecanism, this instead adds a static header of 10K, which will be filled with the header, leading to a hard limit for comment (limit which depends of the artist, title and album size, as well the Xing frame size.

Appreciate this is far from optimal, but hopefully we can find an acceptable trade-off

@acolombier acolombier force-pushed the feat/store-tracklist-as-comment branch 3 times, most recently from 5108a46 to acc29fb Compare October 13, 2024 19:45
@acolombier acolombier marked this pull request as ready for review October 13, 2024 22:04
@Swiftb0y Swiftb0y requested a review from daschuer October 14, 2024 12:51
@Swiftb0y
Copy link
Member

considering the complications and tradeoffs there are with writing large metadata, why not write this tracklist as a separate file like the cuesheet? Is there that much value to having it part of the file metadata?

@acolombier
Copy link
Member Author

acolombier commented Oct 14, 2024

considering the complications and tradeoffs there are with writing large metadata, why not write this tracklist as a separate file like the cuesheet? Is there that much value to having it part of the file metadata?

Because that's not the feature 😃

We already support the ability to generate a cue file, but there was a requested feature to have the ability to store the track. I think that's a fair request as the cue file isn't embedded.
I sometime copy recording of set I have made on my phone, and having a way to check the tracklist as comment metadata would be a great value

@Swiftb0y
Copy link
Member

fully agree, I just find it weird that its a different format from the cuesheet, so I figured these were two different features.

@Holzhaus
Copy link
Member

Holzhaus commented Oct 14, 2024

Didn't check the code, but I was wondering: Is this only for MP3/ID3?

For FLAC I think there is the CUESHEET tag block which is specifically for this purpose and might have proper support by audio players.

@Holzhaus
Copy link
Member

@acolombier
Copy link
Member Author

acolombier commented Oct 14, 2024

I was wondering: Is this only for MP3/ID3?

Yes - only for MP3/ID3 and Wave so far. Since the FLAC encoder inherits the Wave one, it would also support the COMMENT field to be filled up.

https://www.xiph.org/flac/format.html#metadata_block_cuesheet

Nice, I'm wondering how widely is this supported? It feels like some custom logic that could be added in the recordermanager to duplicate the sheets in the FLAC file before flushing. It sounds a bit hacky, but I don't think other format would support cuesheet within their tag's spec?

@JoergAtGithub JoergAtGithub added this to the 2.6-beta milestone Jan 4, 2025
@acolombier acolombier force-pushed the feat/store-tracklist-as-comment branch from bfe592c to d072fbc Compare February 14, 2025 01:05
@acolombier
Copy link
Member Author

acolombier commented Feb 23, 2025

(Edit: didn't work :( )
/softfix

@github-actions github-actions bot force-pushed the feat/store-tracklist-as-comment branch from d072fbc to 0a8ab06 Compare February 23, 2025 02:40
@acolombier acolombier force-pushed the feat/store-tracklist-as-comment branch from 0a8ab06 to d072fbc Compare February 23, 2025 02:41
@acolombier acolombier force-pushed the feat/store-tracklist-as-comment branch from 0bfc6b4 to eba3cfd Compare February 23, 2025 02:57
@github-project-automation github-project-automation bot moved this to In progress in Releases Mar 25, 2025
@acolombier acolombier moved this from In progress to Need testing in Releases Mar 25, 2025
Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm it works for mp3, but unfortunately not for wav.

@acolombier acolombier requested a review from daschuer April 26, 2025 18:39
@acolombier acolombier force-pushed the feat/store-tracklist-as-comment branch from 158cdaa to 9f54851 Compare April 26, 2025 18:50
@daschuer
Copy link
Member

I have this is Mixxx. It remains after reloading form track and utf8 is used:
grafik
This is vlc player:
grafik
grafik
grafik

@daschuer
Copy link
Member

https://mutagen-specs.readthedocs.io/en/latest/id3/id3v2.2.html#comments
In the header the encoding is 00 = latin1. Mixxx writes 03 = utf8.
Lame writes comments as Latin1:
https://github.com/intervigilium/liblame/blob/dd48f963e34c1ef0b831083e87a08097464ee3b0/jni/lame/id3tag.c#L601
So you proably need to use taglib to write unicode or hack something up with lame.

@acolombier
Copy link
Member Author

Ah that makes sense! Now that you pointed this out, I just thought I could use TagLib instead of liblame. I have reworked it and it works great across the board (ffprobe, vlc, mixxx tested)

The only rough edge is the ellipsis/UTF8 truncating, but I believe this is edge case enough the ignore for now. In case we get complains, we can always focus on solving the root cause problem, which is a limitation in the encoder callback API, not allowing to prepend data.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh just noticed I had a pending review.

@daschuer
Copy link
Member

Mp3 looks good now. Wave encoding has still an issue.
grafik
Can we use taglib for all?

@acolombier
Copy link
Member Author

Can we use taglib for all?

Yep, that sounds like a wise approach.

@daschuer
Copy link
Member

The first recording after enable tracklist does not work.

  • Select WAV encoding
  • Disable tracklist
  • Restart Mixxx
  • Enable tracklist
  • Start recording
  • No tracklist is logged
    Expexted result
  • Tracklist shall b e logged.

@acolombier
Copy link
Member Author

I have pushed a rewrite of the wave encoder with TagLib. Sadly, the whole LIST frame doesn't get generated by TagLib, so I had to build the header dynamically. There is some edge cases that aren't handled (e.g int overflow) but I think is edge enough to be ignored.
Looking at the libsndfile, it sounds like utf8 is not officially supported, but ffprobe, VLC and Mixxx both now show it fine, so it's probably good enough.

I believe I also fixed the bug you had found.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can no longer make the feature work for wav.

@acolombier
Copy link
Member Author

Could you share some more details @daschuer? Just tested locally with WAV and everything seems to work fine on my end.

@acolombier acolombier force-pushed the feat/store-tracklist-as-comment branch from 95315d7 to 2bd40a3 Compare February 3, 2026 22:42
@daschuer
Copy link
Member

daschuer commented Feb 4, 2026

pre-commit is complaining.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for coming back to this. It works like a charm for mp3 and wav. Left w view final comments.

// Currently this method is used before init() once to save artist, title and album
//
void EncoderFfmpegCore::updateMetaData(const QString& artist, const QString& title, const QString& album) {
void EncoderFfmpegCore::updateMetaData(const QString& artist,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function does now only print a debug message. Is this desired? Is the comment outdated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reasons, the previously set values (m_strMetaData*) was never read so this appears to have no action. I have set it to a no-op now.

@acolombier acolombier requested a review from daschuer February 8, 2026 22:40
@acolombier acolombier force-pushed the feat/store-tracklist-as-comment branch from ea5423f to 3b5e234 Compare February 9, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Need testing

Development

Successfully merging this pull request may close these issues.

write list of tracks played to comments tag of recordings

5 participants