Skip to content

Opus: Support reading/writing the 'output_gain' header field #916

Closed

Description

@Moonbase59

I’m currently adding Opus support to my loudgain loudness tagger but I’m unsure how to read an Opus file’s 'output_gain' header field using TagLib. I couldn’t find anything in the properties.

Any insights, please?

Activity

  1. Moonbase59 commented on Sep 6, 2019

    @Moonbase59
    Author

    In a perfect situation, this should even be writable (or least be able to set to zero).

    Rationale: Needed for ReplayGain calculation, since the R128_TRACK_GAIN and R128_ALBUM_GAIN values are only an offset based on the 'output_gain'. Setting it back to zero to achieve "clean" ReplayGain values is usually done by encoders only, but might be good to have in a ReplayGain tagger, too.

  2. changed the title [-]Opus: How to read the 'output_gain' header field?[/-] [+]Opus: Support reading/writing the 'output_gain' header field[/+] on Sep 12, 2019
  3. Moonbase59 commented on Sep 12, 2019

    @Moonbase59
    Author

    Probably every tagger or player written to use TagLib might need this. Here is an excerpt from the section of the OggOpus spec on the new R128 gain tags:

    If present, R128_TRACK_GAIN and R128_ALBUM_GAIN MUST correctly
    represent the R128 normalization gain relative to the 'output gain'
    field specified in the ID header. If a player chooses to make use of
    the R128_TRACK_GAIN tag or the R128_ALBUM_GAIN tag, it MUST apply
    those gains in addition to the 'output gain' value. If a tool
    modifies the ID header's 'output gain' field, it MUST also update or
    remove the R128_TRACK_GAIN and R128_ALBUM_GAIN comment tags if
    present. An encoder SHOULD assume that by default tools will respect
    the 'output gain' field, and not the comment tag.
    

    So all the R128_* tags are always relative to the 'output_gain' which means a player must be able to read both, and a tagger must be able to even write it.

    Header writing again … :-(

  4. ufleisch commented on May 7, 2026

    @ufleisch
    Contributor

    Implemented with #1320.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions