Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Suppress pydub ffmpeg warning on import (#4603)

Benjamin Hackl80fd11efbc3c
diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py
index f4d8194da..21425af75 100644
--- a/manim/scene/scene_file_writer.py
+++ b/manim/scene/scene_file_writer.py
@@ -6,6 +6,7 @@ __all__ = ["SceneFileWriter"]
import json
import shutil
+import warnings
from fractions import Fraction
from pathlib import Path
from queue import Queue
@@ -17,7 +18,17 @@ import av
import numpy as np
import srt
from PIL import Image
-from pydub import AudioSegment
+
+# Manim handles audio conversion through PyAV directly. Importing pydub emits a
+# RuntimeWarning if ffmpeg/avconv is not on PATH, even when only WAV code paths
+# are used (which do not need ffmpeg). Silence this specific warning.
+with warnings.catch_warnings():
+ warnings.filterwarnings(
+ "ignore",
+ message=r".*ffmpeg or avconv.*",
+ category=RuntimeWarning,
+ )
+ from pydub import AudioSegment
from manim import __version__