Skip to content

12109 metadata export fix - #12515

Merged
saintmatthieu merged 7 commits into
audacity:masterfrom
saintmatthieu:12109-metadata-export-fix
Oct 26, 2026
Merged

saintmatthieu merged 7 commits into
audacity:masterfrom
saintmatthieu:12109-metadata-export-fix

Conversation

@saintmatthieu

Copy link
Copy Markdown
Contributor

Resolves: #12109

Using the libid3tags library is the main fix.
However, there were other smaller metadata bugs:

  • drag-and-drop imports didn't import metadata at all
  • Exporting with Opus didn't import or export the tags
  • Title and Artist fields were mingled

Unit tests were written for each of those.
(Another bug was found in the doing, but it's a separate place, so it got a ticket of its own: #12511)

  • I signed CLA
  • This PR includes AI assistance
  • If the PR is AI-assisted, I have read, understood and complied with the guidelines for AI-assisted contributions
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

@saintmatthieu saintmatthieu self-assigned this Oct 16, 2026
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ca9e9892-5442-494e-bea4-2d745656da3d
📥 Commits

Reviewing files that changed from the base of the PR and between d7293e8 and a126c11.

📒 Files selected for processing: 1
  • src/importexport/export/tests/environment.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The import/export modules now link libid3tag and enable USE_LIBID3TAG. Metadata handling updates title lookup and commits successful track imports before cleanup. New tests verify standard-tag writes, metadata round trips, and ID3 version 3 for supported formats. The default importer order places Opus between OGG and FLAC.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to a126c

Tests for four export formats can fail in a supported system-dependency build. Resolve the ID3 assertion mismatch before merging.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly identifies the issue number and the primary metadata export fix. It is concise and related to the main changes.
Description check Passed The description includes the issue link, change summary, motivation, related bug information, and completed checklist items. It satisfies the repository template.
Linked Issues check Passed Issue #12109 requires metadata tags in exported MP3 files. The PR links libid3tag to the MP3 module and enables USE_LIBID3TAG. metadataroundtrip_tests.cpp exports MP3 with title, artist, album, …
Out of Scope Changes check Passed The changes stay within metadata import and export scope. The Opus, drag-and-drop import, and Title/Artist fixes address metadata behavior stated in the current PR description. The dependency wiring a…
Full details: Linked Issues check

Explanation

Issue #12109 requires metadata tags in exported MP3 files. The PR links libid3tag to the MP3 module and enables USE_LIBID3TAG. metadataroundtrip_tests.cpp exports MP3 with title, artist, album, track, year, genre, comments, and a non-ASCII title, then imports the file and compares each tag. The test also checks for an ID3v2.3 tag at the MP3 file start.

Full details: Out of Scope Changes check

Explanation

The changes stay within metadata import and export scope. The Opus, drag-and-drop import, and Title/Artist fixes address metadata behavior stated in the current PR description. The dependency wiring and round-trip tests support that behavior. No unrelated change is demonstrated.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/musescore.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8ad3f0ee-a866-4c95-bc1f-ee4359c5f9b2
📥 Commits

Reviewing files that changed from the base of the PR and between fd6aaec and d7293e8.

📒 Files selected for processing: 15
  • au3/libraries/au3-import-export/Import.cpp
  • au3/modules/import-export/mod-flac/CMakeLists.txt
  • au3/modules/import-export/mod-mp2/CMakeLists.txt
  • au3/modules/import-export/mod-mp3/CMakeLists.txt
  • au3/modules/import-export/mod-pcm/CMakeLists.txt
  • buildscripts/cmake/DependencyManifest.cmake
  • muse_deps
  • src/importexport/export/tests/CMakeLists.txt
  • src/importexport/export/tests/environment.cpp
  • src/importexport/export/tests/metadataroundtrip_tests.cpp
  • src/importexport/import/internal/au3/au3importer.cpp
  • src/project/internal/au3/au3metadata.cpp
  • src/project/tests/CMakeLists.txt
  • src/project/tests/au3metadata_tests.cpp
  • src/project/types/projectmeta.h
💤 Files with no reviewable changes: 1
  • src/project/internal/au3/au3metadata.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

FLAC::FLAC
FLAC::FLAC++
rapidjson::rapidjson
libid3tag::libid3tag

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is libid3tag needed for all these formats?
Currently FLAC is exported just fine on master and 4.0.1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good observation, I didn't realize that. I dug into this, and it's a bit complicated once again :)

ImportFLAC.cpp uses it:

#ifdef USE_LIBID3TAG
    // Skip any ID3 tags that might be present
    id3_byte_t query[ID3_TAG_QUERYSIZE];
    cnt = binaryFile.Read(query, sizeof(query));
    cnt = id3_tag_query(query, cnt);
    binaryFile.Seek(cnt);
#endif

    char buf[5];
    cnt = binaryFile.Read(buf, 4);
    binaryFile.Close();

    if (cnt == wxInvalidOffset || strncmp(buf, FLAC_HEADER, 4) != 0) {
        // File is not a FLAC file
        return nullptr;
    }

The code skips ID3 tags present in a flac's header, because otherwise the if after wouldn't recognize it as a flac file. The comment doesn't say why an ID3 tag might be present in a flac header, the bot hypothesizes that some file taggers can add ID3 tags to a flac file. In any case, the dev who wrote this (I didn't look who) must've hit this case.

What would happen with such a file without us using libid3tag? Looks like ffmpeg would catch it: I just tried the TEST_P(MetadataRoundTripTests, TagsSurviveExportAndImport) with FFmpeg at the beginning of the wxT("AUP,PCM,OGG,Opus,FLAC,MP3,LOF,WavPack,portsmf,FFmpeg") list in Import.cpp. The test fails because the Artist and Year fields are empty, but otherwise it's fine.

To complicate things some more: in your experiment, ExportFLAC.cpp does the export, but it's actually ImportPCM that does the import :) libsndfile uses flac (set(DEP_DEPENDS ogg vorbis flac opus) in libsndfile's spec.cmake), and since it's tried before FLAC, it works.

According to the bot, which created an experiment where an ID3 tag was added to a flac file, both libsndfile and ffmpeg can handle it. So in summary: if we remove this dependency, it'd only bite us the day we drop libsndfile and ffmpeg.

In principle it's better to keep it, but if for some reasons we should remove this dependency, there'd be two safety belts. I don't see the harm in keeping it, though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oh, I would never imagine that metadata topic might be so complicated. Thank you for the detailed answer.

@saintmatthieu
saintmatthieu force-pushed the 12109-metadata-export-fix branch from d7293e8 to a126c11 Compare October 20, 2026 17:04
[  FAILED  ] 9 tests, listed below:
[  FAILED  ] AllFormatsWithMetadata/MetadataRoundTripTests.TagsSurviveExportAndImport/MP3, where GetParam() = MP3
[  FAILED  ] AllFormatsWithMetadata/MetadataRoundTripTests.TagsSurviveExportAndImport/MP2, where GetParam() = MP2
[  FAILED  ] AllFormatsWithMetadata/MetadataRoundTripTests.TagsSurviveExportAndImport/WAV, where GetParam() = WAV
[  FAILED  ] AllFormatsWithMetadata/MetadataRoundTripTests.TagsSurviveExportAndImport/AIFF, where GetParam() = AIFF
[  FAILED  ] AllFormatsWithMetadata/MetadataRoundTripTests.TagsSurviveExportAndImport/Opus, where GetParam() = Opus
[  FAILED  ] AllFormatsWithMetadata/MetadataRoundTripTests.WritesId3v23Tag/MP3, where GetParam() = MP3
[  FAILED  ] AllFormatsWithMetadata/MetadataRoundTripTests.WritesId3v23Tag/MP2, where GetParam() = MP2
[  FAILED  ] AllFormatsWithMetadata/MetadataRoundTripTests.WritesId3v23Tag/WAV, where GetParam() = WAV
[  FAILED  ] AllFormatsWithMetadata/MetadataRoundTripTests.WritesId3v23Tag/AIFF, where GetParam() = AIFF

Assisted-by: Claude w Opus 5.5
Fixes a lot, but not all written tests:
[  FAILED  ] 1 test, listed below:
[  FAILED  ] AllFormatsWithMetadata/MetadataRoundTripTests.TagsSurviveExportAndImport/Opus, where GetParam() = Opus

Assisted-by: Claude w Opus 5.5
Add Opus to the ordered preference list of codec candidates

No more failing tests

Assisted-by: Claude w Opus 5.5
@saintmatthieu
saintmatthieu force-pushed the 12109-metadata-export-fix branch from a126c11 to e8a7ff2 Compare October 26, 2026 10:27
@saintmatthieu
saintmatthieu merged commit 9298ad8 into audacity:master Oct 26, 2026
9 of 10 checks passed
@saintmatthieu
saintmatthieu deleted the 12109-metadata-export-fix branch October 26, 2026 10:27
@grliszas14 grliszas14 mentioned this pull request Oct 27, 2026
6 of 8 tasks
saintmatthieu added a commit that referenced this pull request Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metadata is not written to MP3 files during export

2 participants