Repository navigation
Audio: keep PyAV decoding working on PyAV 19, and stop the tests needing an AMR encoder - #12295
Merged
Merged
Conversation
…ing an AMR encoder
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…, not a flat 48000
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PyAV 19.0.0 was released on 2026-09-29 at 17:46 UTC. Within 15 minutes,
(Python 3.13, l-r)went red: five tests intest_llama_audio_attachment_container.pyfailed withUnknownCodecError: amr_nb. Underneath that is a product break that affects real users.Two problems
1. Product: every PyAV decode fails on PyAV 19.
PyAV 19 removed the
metadata_errorskeyword fromav.open(). Four call sites pass it, and each one now raisesTypeErrorbefore reading anything:studio/backend/routes/inference.py(chat audio attachments: wma, amr, m4a and the rest PyAV handles)studio/backend/core/inference/stt_sidecar.py(speech to text)studio/backend/utils/datasets/audio_decode.py(audio datasets in Studio)unsloth/import_fixes.py(the library's torchcodec-free audio dataset fallback)Who is exposed:
unslothitself (av>=12.3.0) and Windows ARM64 Studio (av>=17.0.0) resolve to 19.0.0 today.av==15.1.0and are not affected yet.On main with PyAV 19, seven STT sidecar tests that decode through real PyAV fail too, alongside the five above.
2. Tests: the AMR fixture needs an encoder PyAV 19 no longer ships.
The 19.0.0 wheels still decode AMR-NB and AMR-WB but have no AMR encoder.
_encode_amr()built its fixture withadd_stream("amr_nb"), so the test failed before reaching the decoder it exists to check.3. Tests: the WebM export check relied on AAC padding.
test_video_gallery.py::test_webm_export_keeps_the_audio_trackasserted at least 48000 decoded samples after exporting a 1 s clip. PyAV 18 decoded that 1 s AAC fixture with its encoder padding (45056 samples at 44.1 kHz); PyAV 19 trims it to the true 44100. With the padding gone, a correct export decodes to 47983, and the flat floor fails. The exporter is unchanged and correct.The test now compares against the decoded source's duration, allowing one 20 ms Opus frame (960 samples) for resampling and framing at the edges. A mute or truncated track still fails by a wide margin.
test_video_gallery.pypasses on PyAV 19.0.0, 18.1.0 and 15.1.0.Changes
_av_open(av, source)helper at each site (_audio_av_openinimport_fixes.py, which mirrors Studio's copy). It passesmetadata_errors = "ignore"as before. If PyAV rejects that keyword by name, it retries without it; any otherTypeErrorstill propagates. The retry spellsformat = None, which is PyAV's default (probe the container), sotest_text_io_encoding.pydoes not read it asPath.open().tests/test_datasets_audio_fallback.py: the library/Studio drift check now covers the new helper pair as well.av:TypeError.Testing
Studio audio, STT and text-encoding suites (
tests/*audio*,tests/*stt*,tests/test_text_io_encoding.py):test_llama_audio_attachment_container.py: 61 passed on PyAV 19.0.0, 18.1.0 and 15.1.0.tests/test_datasets_audio_fallback.py: 15 passed. Changing one character in only the library copy of the helper fails the drift check.av.open(..., format = None)works on both 15.1.0 and 19.0.0.