Check that FLAC and Opus are FLAC and Opus #233

Merged
JMR-dev merged 1 commits from test/flac-and-opus-assert-their-format into main 2026-09-06 03:45:47 +00:00
JMR-dev commented 2026-09-06 03:36:33 +00:00 (Migrated from github.com)

Closes #228.

encodesFlacLosslessAudio and encodesOpus asserted only that a non-empty file appeared. Five siblings in the same class check what is in it — encodesWav reads RIFF two lines away, and GIF, Matroska, MP3, H.264 and H.265 all assert a container marker or a track MIME.

Why it matters

convert() throws on a non-zero return code, so these two did prove the command ran. What they could not distinguish is the command running and producing the wrong thing — a failure mode this codebase has already had once: F1 in docs/coverage-read-findings.md records a live Vorbis arm in FFmpegCommandBuilder that ContainerCapabilities says cannot exist.

Mutation: point OutputFormat.FLAC's arm at pcm_s16le. Both tests stayed green.

The change

Four bytes each, in the idiom the class already uses:

format container ffmpeg -f marker
OutputFormat.FLAC Container.FLAC flac fLaC
OutputFormat.OPUS Container.OGG ogg OggS

Opus asserts the container marker rather than the codec — that is what the other container-level assertions in this class check, and it is four bytes at offset 0.

Verification

Both muxers were driven directly to confirm the markers rather than inferring them from the codec name:

$ ffmpeg -f lavfi -i sine=... -c:a flac   -f flac t.flac  && head -c4 t.flac  # fLaC
$ ffmpeg -f lavfi -i sine=... -c:a libopus -f ogg  t.opus && head -c4 t.opus  # OggS

The marker belongs to the container, so it does not vary with the ffmpeg build. CI's five legs run the assertions against the shipped ffmpeg-kit.

🤖 Generated with Claude Code

Closes #228. `encodesFlacLosslessAudio` and `encodesOpus` asserted only that a non-empty file appeared. Five siblings in the same class check what is *in* it — `encodesWav` reads `RIFF` two lines away, and GIF, Matroska, MP3, H.264 and H.265 all assert a container marker or a track MIME. ## Why it matters `convert()` throws on a non-zero return code, so these two did prove the command *ran*. What they could not distinguish is the command running and producing **the wrong thing** — a failure mode this codebase has already had once: **F1** in `docs/coverage-read-findings.md` records a live Vorbis arm in `FFmpegCommandBuilder` that `ContainerCapabilities` says cannot exist. *Mutation:* point `OutputFormat.FLAC`'s arm at `pcm_s16le`. Both tests stayed green. ## The change Four bytes each, in the idiom the class already uses: | format | container | ffmpeg `-f` | marker | |---|---|---|---| | `OutputFormat.FLAC` | `Container.FLAC` | `flac` | `fLaC` | | `OutputFormat.OPUS` | `Container.OGG` | `ogg` | `OggS` | Opus asserts the **container** marker rather than the codec — that is what the other container-level assertions in this class check, and it is four bytes at offset 0. ## Verification Both muxers were driven directly to confirm the markers rather than inferring them from the codec name: ``` $ ffmpeg -f lavfi -i sine=... -c:a flac -f flac t.flac && head -c4 t.flac # fLaC $ ffmpeg -f lavfi -i sine=... -c:a libopus -f ogg t.opus && head -c4 t.opus # OggS ``` The marker belongs to the container, so it does not vary with the ffmpeg build. CI's five legs run the assertions against the shipped ffmpeg-kit. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.