Skip to content

--audio-format=dts can never succeed: the dca encoder is experimental and rdlp never sets strict_std_compliance #639

Description

@crippledgeek

Found while verifying #638's format matrix. Independent of #638's frame-size/sample-format adaptation — that fix landed and took the extract matrix from 2/14 to 13/14 formats. dts is the remaining one, and it fails for a different reason.

Symptom

With #638's fix in place, AudioExtractStage over a stereo 48 kHz AAC source:

dts: audio extract stage failed: failed to open audio encoder for transcode:
     FFmpeg library error: Experimental feature
[dca @ ...] The encoder 'dca' is experimental but experimental codecs are not
            enabled, add '-strict -2' if you want to use it.

The failure is at avcodec_open2, before any frame is sent — so it is not an adaptation problem.

Ground truth

$ ffmpeg -i stereo48.mp4 -vn -c:a dca out.dts            # 0 bytes, "Terminating thread with return code -22"
$ ffmpeg -i stereo48.mp4 -vn -c:a dca -strict -2 out.dts # 354192 bytes, OK

Root cause

AUDIO_CODECS maps dts → encoder dca (crates/rdlp-ffmpeg/src/ffmpeg/audio_codecs.rs), but nothing in the extract path sets strict_std_compliance on the encoder context. FFmpeg's native dca encoder is marked experimental, so avcodec_open2 refuses it at the default compliance level.

So --audio-format=dts is an advertised option that cannot succeed on any build using the native encoder.

Options

  1. Set strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL on the encoder context when — and only when — the selected encoder is flagged experimental (AV_CODEC_CAP_EXPERIMENTAL). Generic, and covers any future experimental encoder rather than special-casing dca.
  2. Prefer a non-experimental encoder when one exists in the build (e.g. libdca where linked), falling back to (1).
  3. Reject --audio-format=dts up front with a message naming the experimental gate, rather than failing deep in the stage.

(1) is closest to ffmpeg's own -strict -2 and keeps the option honest; it should be opt-in per-encoder rather than a blanket compliance downgrade.

Acceptance

  • --audio-format=dts produces a decodable DTS file, or fails with a message that names the experimental-codec gate instead of a bare "Experimental feature".
  • The decision is driven by the encoder's AV_CODEC_CAP_EXPERIMENTAL capability, not a hardcoded dca string.
  • Negative test that fails against today's code.
  • dts is re-enabled in the audio_extract_format_matrix suite (it is currently excluded there with a pointer to this issue).

Refs #638

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