Remove pydub dependency#529
Conversation
Replace pydub with stdlib `wave` for WAV output and a direct ffmpeg subprocess for MP3. pydub is unmaintained and incompatible with Python 3.14 (depends on the removed stdlib `audioop` module). Closes #528 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🪼 branch checks and previews
|
🦄 change detectedThis Pull Request includes changes to the following packages.
|
🪼 branch checks and previews
Install Trackio from this PR (includes built frontend) pip install "https://huggingface.co/buckets/trackio/trackio-wheels/resolve/a715d04222a3c7af60c85887c62aade454680b73/trackio-0.24.1-py3-none-any.whl" |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Pull request overview
This PR removes the unmaintained pydub dependency from Trackio’s media pipeline (addressing Python 3.13+ audioop removal) by switching WAV writing to the stdlib wave module and MP3 encoding to a direct ffmpeg subprocess, and updates tests accordingly.
Changes:
- Replace
pydub-based audio export with stdlibwave(WAV) and directffmpeginvocation (MP3). - Update MP3 verification tests to use
ffprobeinstead ofpydub. - Remove
pydubfrompyproject.tomland delete the pydub-related warning filter from an example script.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| trackio/media/utils.py | Adjusts the ffmpeg missing error message to be media-format-generic. |
| trackio/media/audio.py | Removes pydub; implements WAV writing via wave and MP3 writing via ffmpeg piping PCM. |
| tests/unit/test_audio_writer.py | Replaces pydub MP3 inspection with ffprobe JSON probing. |
| pyproject.toml | Drops pydub from runtime dependencies. |
| examples/crash-and-resume-same-run-name.py | Removes pydub-specific SyntaxWarning filter. |
| .changeset/solid-sides-look.md | Adds a minor-version changeset for the dependency removal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "trackio": patch | ||
| --- | ||
|
|
||
| feat:Remove pydub dependency |
There was a problem hiding this comment.
Minor formatting: add a space after feat: so the changeset summary reads cleanly (e.g., feat: Remove pydub dependency).
| feat:Remove pydub dependency | |
| feat: Remove pydub dependency |
| "-ac", | ||
| str(channels), | ||
| "-i", | ||
| "pipe:0", |
There was a problem hiding this comment.
The ffmpeg invocation relies on the output filename’s extension to select the output container/codec. That changes behavior vs the previous pydub.export(..., format=format) path: if format="mp3" but the filename has an unknown/mismatched extension, ffmpeg will error or encode to the extension’s format. Consider explicitly specifying the output format/codec (e.g., -f mp3 and/or -codec:a libmp3lame) so the format argument always controls the encoding regardless of filename.
| "pipe:0", | |
| "pipe:0", | |
| "-f", | |
| format, | |
| "-codec:a", | |
| "libmp3lame", |
|
Going to merge this in for a patch release |
Summary
audioopmodule removed in 3.13+). Closes Pydub dependency is causing problems even when audio isn't wanted #528.wavefor WAV output and a directffmpegsubprocess for MP3 — pydub was only shelling out to ffmpeg for MP3 anyway, so this cuts out the middleman.tests/unit/test_audio_writer.pyforffprobe.pydub<1.0.0frompyproject.tomland the pydubSyntaxWarningfilter in the crash-and-resume example.check_ffmpeg_installed()error message (previously said "required to write video" — it covers audio too).Behavior is unchanged for users without ffmpeg: WAV still works (stdlib only), MP3 still raises the same
RuntimeErrorvia the existingcheck_ffmpeg_installed()gate.