Skip to content

ReplayGain metaflac backend alters input files #6915

Description

@ludelafo

Problem

When using the ReplayGain plugin with the metaflac backend, the current implementation works in two parts:

  1. Write the ReplayGain tags to the input files (source: beetsplug/replaygain.py#L709-L712).
  2. Read the ReplayGain tags from the input files (source: beetsplug/replaygain.py#L714-L733).

This leads to altering the input files, which corrupts files that shouldn't be touched, especially when the input files are not in the final destination (e.g., during import).

metaflac can use --scan-replay-gain to read the ReplayGain tags without altering the input files (since FLAC 1.3.2, released on 01-Jan-2017 - discussed in #1203).

Using --scan-replay-gain instead of --add-replay-gain would fix this issue.

Minimal reproduction

  1. config.yaml:

    directory: /music
    import:
      copy: yes
    replaygain:
      auto: yes
      backend: metaflac
  2. Import a FLAC file with no ReplayGain tags:

    beet import /downloads/file.flac
  3. Check the ReplayGain tags on the copy beets created in the library: metaflac --list /music/.../file.flac - tags are present, as expected.

  4. Check the ReplayGain tags on the original file that was imported from: metaflac --list /downloads/file.flac - tags were also written here, unexpectedly.

Setup

  • OS: Debian GNU/Linux 13.6 (trixie) in a Visual Studio Devcontainer
  • Python version: 3.13.5
  • beets version: 2.13.1 (released on 29-Jul-2026)
  • Turning off plugins made problem go away (yes/no): N/A

AI disclaimer

I have used AI to help me write this issue report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions