fix: suppress pydub RuntimeWarning when ffmpeg is not installed#1692
Open
xor-xe wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: suppress pydub RuntimeWarning when ffmpeg is not installed#1692xor-xe wants to merge 1 commit intomicrosoft:mainfrom
xor-xe wants to merge 1 commit intomicrosoft:mainfrom
Conversation
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
VANDRANKI
reviewed
Apr 10, 2026
VANDRANKI
left a comment
There was a problem hiding this comment.
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.
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.
Description
When
pydubis imported on a system withoutffmpegoravconvinPATH, it emits aRuntimeWarningat import time — even when no audio conversion is being performed. This affects any user who has theaudio-transcriptionextras installed.The existing
warnings.catch_warnings()block in_transcribe_audio.pyalready suppressesDeprecationWarningandSyntaxWarningon import, butRuntimeWarningwas 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 allRuntimeWarnings. If ffmpeg is actually missing when audio conversion is attempted, pydub will raise a proper error at that point anyway.Related
Fixes #1685