Skip to content

bug(postprocess): --recode-audio=auto into .ogg writes Opus, but .ogg means Vorbis (Xiph / RFC 7845) #623

Description

@crippledgeek

Found while designing the #618 fix (container → default audio encoder). Split out
because it undoes a deliberate existing choice and is a user-visible behaviour change
in its own right, rather than part of #618's catch-all removal.

The defect

audio_encoder_registry::select_audio_encoder_for_container
(crates/rdlp-ffmpeg/src/ffmpeg/audio_encoder_registry.rs:368) overrides
ContainerFormat::Ogg to Opus:

ContainerFormat::Ogg => preferred_audio_encoder("opus")
    .or_else(|| preferred_audio_encoder("vorbis"))
    .unwrap_or("libopus"),

FFmpeg's ogg muxer declares vorbis as its default audio codec (measured:
av_guess_format("x.ogg") → muxer ogg, av_guess_codec(AUDIO)vorbis).

So --recode-audio=auto targeting .ogg writes Opus inside a file whose extension
signals Vorbis
.

Why that's wrong

Xiph.Org — MIME Types and File Extensions:

".ogg applies now for Vorbis I files only."

The wiki adds that .ogg was "more recently also been used for Ogg FLAC and for Theora,
too — these uses are deprecated now in favor of .oga and .ogv respectively", with the
rationale given as backwards-compatibility with hardware players.

[RFC 7845] §9 ("Content Type"):

"The RECOMMENDED filename extension for Ogg Opus files is '.opus'."

Neither source forbids Opus-in-.ogg, so this is a conformance/expectation issue
rather than a spec violation. But hardware players that treat .ogg as Vorbis are
exactly the population the Xiph recommendation exists to protect.

Precedent

This is the same class as #538, where --remux=wmv wrote Title.asf. The resolution
there was that the extension the user asked for wins over internal canonicalisation,
and Wmv/Wma/Asf became distinct variants so the spelling survived to the output
filename.

rdlp already has a separate ContainerFormat::Opus mapping to .opus, so a user who
wants Opus has a correct and unambiguous way to ask for it. The override gives Opus to
users who did not ask for it.

Options

  1. Drop the overrideOgg resolves to the muxer default (vorbis). Most
    conformant; matches the bug(postprocess): --remux wmv produces a .asf file, inverting Microsoft's own naming rule #538 precedent. Cost: quality regression vs Opus for anyone
    relying on the current behaviour.
  2. Add an Oga variant for .oga (Xiph's extension for non-Vorbis Ogg audio) and
    route Opus-in-Ogg there. More complete, larger change, and .oga has poor real-world
    player support.
  3. Keep as-is, documenting the deviation explicitly rather than leaving it implicit.

Leaning toward (1) on the #538 precedent, but it is a judgement call about existing
user-visible behaviour, not a clear-cut bug.

Verified vs not

Verified (measured against the linked FFmpeg build, 2026-07-22):

  • ogg muxer declares vorbis; .opus resolves to the opus muxer declaring opus.
  • rdlp has no Oga variant; Ogg and Opus are both in is_audio_only().
  • The Xiph and RFC 7845 quotes above are verbatim from the cited pages.

NOT verified — do not treat as established:

  • What yt-dlp does by default for .ogg targets. A search was inconclusive; read the
    postprocessor source before citing it as prior art either way.
  • Whether any specific hardware player actually rejects Opus-in-.ogg. The Xiph
    rationale asserts the compatibility concern; I did not test a device.
  • Whether any rdlp user depends on the current Opus behaviour.

Acceptance

  • A decision recorded among the three options, with rationale
  • If (1): Ogg resolves via the muxer default; test asserts .ogg → vorbis and
    .opus → opus, and that the two do not collapse
  • Behaviour change noted in the changelog if user-visible

Refs #618, #538

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions