Skip to content

fix: suppress pydub RuntimeWarning when ffmpeg is not installed#1692

Open
xor-xe wants to merge 1 commit intomicrosoft:mainfrom
xor-xe:fix/pydub-ffmpeg-runtime-warning
Open

fix: suppress pydub RuntimeWarning when ffmpeg is not installed#1692
xor-xe wants to merge 1 commit intomicrosoft:mainfrom
xor-xe:fix/pydub-ffmpeg-runtime-warning

Conversation

@xor-xe
Copy link
Copy Markdown

@xor-xe xor-xe commented Apr 10, 2026

Description

When pydub is imported on a system without ffmpeg or avconv in PATH, it emits a RuntimeWarning at import time — even when no audio conversion is being performed. This affects any user who has the audio-transcription extras installed.

The existing warnings.catch_warnings() block in _transcribe_audio.py already suppresses DeprecationWarning and SyntaxWarning on import, but RuntimeWarning was not covered.

Fix

Extend the existing filter block with a targeted filter for pydub's ffmpeg warning:

```python
warnings.filterwarnings("ignore", message=".ffmpeg.", category=RuntimeWarning)
```

Using message=".*ffmpeg.*" keeps the scope narrow — only the specific "Couldn't find ffmpeg or avconv" warning is silenced, not all RuntimeWarnings. If ffmpeg is actually missing when audio conversion is attempted, pydub will raise a proper error at that point anyway.

Related

Fixes #1685

When pydub is imported without ffmpeg present it emits a RuntimeWarning
at import time. The existing warnings.catch_warnings() block already
suppressed DeprecationWarning and SyntaxWarning; extend it to also
filter the ffmpeg-specific RuntimeWarning from pydub so users who are
not doing audio work don't see noisy warnings on every import.

Fixes microsoft#1685
Copy link
Copy Markdown

@VANDRANKI VANDRANKI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct placement - the filter is inside the same warnings.catch_warnings() block that already suppresses DeprecationWarning and SyntaxWarning on import. Using message=".*ffmpeg.*" as the match pattern is specific enough to avoid accidentally suppressing unrelated RuntimeWarnings from other packages.

LGTM.

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.

[Bug]: RuntimeWarning from pydub: "Couldn't find ffmpeg or avconv" on Linux

2 participants