Skip to content

Vorbis or APE to ID3v2 maps LYRICS to 'UNSYNCED LYRICS' #624

Closed

Description

@NekoAlosama

Reproducer

I tried this code (same as #621 ):

fn get_metadata(path: &path::PathBuf) -> (Box<[Tag]>, u32) {
    let tagged_file = Probe::open(path)
        .expect("ERROR: file removed before processing")
        .read()
        .expect("ERROR: file in use");
    let tags = tagged_file.tags().iter().cloned().collect();
    let sample_rate = tagged_file
        .properties()
        .sample_rate()
        .expect("ERROR: file has no sample rate");
    (tags, sample_rate)
}

fn process_metadata(mut tags: Box<[Tag]>, peak: f32) -> Box<[Tag]> {
    for tag in &mut tags {
        tag.remove_empty();

        // File peak will change due to processing
        tag.remove_key(ItemKey::ReplayGainAlbumPeak);

        // Paste the new peak value
        tag.insert_text(ItemKey::ReplayGainTrackPeak, peak.to_string());
    }
    let mut id3v2_tags = tags.clone();
    id3v2_tags
        .iter_mut()
        .for_each(|tag| tag.re_map(TagType::Id3v2));
    let mut riff_tags = tags.clone();
    riff_tags
        .iter_mut()
        .for_each(|tag| tag.re_map(TagType::RiffInfo));

    id3v2_tags.into_iter().chain(riff_tags).collect()
}

fn write_tags(file_path: &Path, tags: Box<[Tag]>) {
    for tag in tags {
        _ = tag.save_to_path(file_path, WriteOptions::default());
    }
}

Summary

In response to #621 , I modified my Cargo.toml to depend on the main branch of lofty instead of waiting for 0.23.3. Reiterating here, my DSP project can take a FLAC with Vorbis Comments (none with ID3v2), convert those Vorbis Comments to ID3v2 and RIFF INFO tags, then apply those copied tags to a modified .wav file. I can understand why the USLT can be sourced from different tags (i.e. 'UNSYNCED LYRICS' or UNSYNCED_LYRICS or UNSYNCEDLYRICS, depending on the software used, which is why I actually use all three in my FLAC files), but I don't yet know why the LYRICS tag is dropped and maps to 'UNSYNCED LYRICS' instead. RIFF INFO tags don't support arbitrary tags, including SYLT and USLT, so it has to be the `.re_map(TagType::ID3v2)' producing a problem.

I don't know if this problem is limited to just the Vorbis -> ID3v2 remapping, so I'll try other files with different tag types while I wait.

Expected behavior

No response

Assets

Image

Activity

  1. added
    bug
    on Mar 1, 2026
  2. NekoAlosama commented on Mar 1, 2026

    @NekoAlosama
    Author

    My only other files are MP3 files, for which foorbar2000 supports writing ID3v1, ID3v2.3 or ID3v2.4 (not both), and APEv2 tags, separately or all three at the same time.

    ID3v1 doesn't support arbitrary tags, so it's not really counted here.
    APEv2 has the same behavior, where APEv2 -> ID3v2 maps LYRICS to 'UNSYNCED LYRICS' and 'UNSYNCED LYRICS' maps to nothing.
    ID3v2.3 and ID3v2.4, however, correctly maps 'UNSYNCED LYRICS', but now LYRICS maps to nothing. This implies that the .remap() method doesn't return early if the input tag type is the same as the output tag type, but I don't know if there are further ramifications for doing so. It's not difficult for me to add a check in my code above.

  3. changed the title [-]Vorbis to ID3v2 maps LYRICS to 'UNSYNCED LYRICS'[/-] [+]Vorbis or APE to ID3v2 maps LYRICS to 'UNSYNCED LYRICS', ID3v2 to ID3v2 maps LYRICS to nothing[/+] on Mar 1, 2026
  4. Serial-ATA commented on Mar 1, 2026

    @Serial-ATA
    Owner

    That's a consequence of #561. See the docs for ItemKey::Lyrics: https://docs.rs/lofty/latest/lofty/tag/enum.ItemKey.html#variant.Lyrics

    Not sure what the best solution to the lyrics problem is. In this specific case, the solution would just be to favor ItemKey::UnsyncLyrics and discard ItemKey::Lyrics when doing the generic conversion. If we only have ItemKey::Lyrics though, we don't know if it's synchronized or not.

  5. changed the title [-]Vorbis or APE to ID3v2 maps LYRICS to 'UNSYNCED LYRICS', ID3v2 to ID3v2 maps LYRICS to nothing[/-] [+]Vorbis or APE to ID3v2 maps LYRICS to 'UNSYNCED LYRICS'[/+] on Mar 1, 2026
  6. NekoAlosama commented on Mar 1, 2026

    @NekoAlosama
    Author

    I see, so LYRICS mapping to nothing is the intended behavior for now since there is no actual LYRICS tag in ID3v2 (though I don't know if you can arbitrarily make it), but LYRICS mapping to 'UNSYNCED LYRICS' with timecodes is still an issue here.

    Aside from that, I updated the remapping section of my code above to skip remapping ID3v2 to ID3v2, then keeping only the tag(s) that have the most fields, and the same is done for the RIFF INFO tag.

        let mut id3v2_tags = tags.clone();
        id3v2_tags.iter_mut().for_each(|tag| {
            if tag.tag_type() != TagType::Id3v2 {
                tag.re_map(TagType::Id3v2)
            }
        });
        if let Some(id3v2_fields) = id3v2_tags.iter().map(|tag| tag.len()).max() {
            id3v2_tags = id3v2_tags
                .into_iter()
                .filter(|tag| tag.len() >= id3v2_fields)
                .collect();
        }
  7. Serial-ATA commented on Mar 1, 2026

    @Serial-ATA
    Owner

    I see, so LYRICS mapping to nothing is the intended behavior for now since there is no actual LYRICS tag in ID3v2

    Both ItemKey::Lyrics and ItemKey::UnsyncLyrics map to USLT. The issue is both fields are used for lyrics without timecodes in the wild. I'm open to removing support for ItemKey::Lyrics in ID3v2, but AFAICT that field is more commonly used in other formats for unsynchronized lyrics, so that might be surprising behavior.

  8. added this to the 0.23.3 milestone on Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions