Skip to content

Report the codec name, not the decoder name, in probe/1 - #91

Merged
rubas-agent[bot] merged 3 commits into
mainfrom
fix-probe-codec-name
Oct 16, 2026
Merged

rubas-agent[bot] merged 3 commits into
mainfrom
fix-probe-codec-name

Conversation

@rubas-agent

@rubas-agent rubas-agent Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Before

Exmpeg.probe/1 on main, compared with ffprobe on the same files:

Exmpeg.probe("a.mp3")    -> [{"mp3float", "MP3 (MPEG audio layer 3)"}]
Exmpeg.probe("av1.mkv")  -> [{"libdav1d", "dav1d AV1 decoder by VideoLAN"}]

ffprobe a.mp3            -> mp3,MP3 (MPEG audio layer 3)
ffprobe av1.mkv          -> av1,Alliance for Open Media AV1

Problem

probe/1 reports the name of the first registered decoder, not the codec name. The value changes with the decoders in the FFmpeg build, so a source build and the precompiled NIF can report a different codec for the same file.

After

Exmpeg.probe("a.mp3")    -> [{"mp3", "MP3 (MPEG audio layer 3)"}]
Exmpeg.probe("av1.mkv")  -> [{"av1", "Alliance for Open Media AV1"}]
File codec before codec after ffprobe codec_name
a.mp3 mp3float mp3 mp3
av1.mkv libdav1d av1 av1

h264, aac, vp9, opus, and pcm_s16le stay the same. This is a breaking change for Hex users, and CHANGELOG.md says so under ## Unreleased.

Cause, design, tests

Cause. native/exmpeg_native/src/probe.rs:resolve_codec took name() and long_name() from AVCodec::find_decoder(codec_id).

Design. ffprobe reads both strings from the codec descriptor. rsmpeg has no safe wrapper for avcodec_descriptor_get, so ffi_helpers::codec_descriptor adds one. ffi_helpers is the only module that holds unsafe. The function returns None for an id without a descriptor, and resolve_codec keeps ("unknown", None) for that case, so the contract of Exmpeg.Stream.codec stays. The existing ffi_helpers::codec_name stays as it is, because concat uses it for its error output.

Tests.

  • New Rust unit tests in probe.rs: AV_CODEC_ID_MP3 gives ("mp3", Some("MP3 (MPEG audio layer 3)")), AV1 gives av1, H264 gives h264, AAC gives aac, and AV_CODEC_ID_NONE gives ("unknown", None).
  • task test:rust: 19 passed.
  • task check: exit 0 (fmt, compile, lint, tests, zizmor).
  • task test:integration: 104 passed. These tests assert the names that must not change.

rubas added 3 commits October 16, 2026 15:59
resolve_codec used the name of the first registered decoder, so probe/1
reported "mp3float" for MP3 and "libdav1d" for AV1, and the value
changed with the decoders of the FFmpeg build. Read name and long name
from avcodec_descriptor_get, as ffprobe does.
@rubas-agent
rubas-agent Bot merged commit 61a7750 into main Oct 16, 2026
1 check passed
@rubas-agent
rubas-agent Bot deleted the fix-probe-codec-name branch October 16, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant