mixing.util¶
General utilities for mixing video, audio, etc.
Functions
|
Copy data to system clipboard. |
Resolve an ffmpeg executable, preferring the pip-bundled binary. |
|
Get file path from clipboard and validate it. |
|
Return True if the |
|
|
Raise an informative |
|
Raise an informative |
|
Import a package, raising an informative error if not installed. |
|
Convert time value to seconds based on unit. |
- mixing.util.ffmpeg_exe()[source]¶
Resolve an ffmpeg executable, preferring the pip-bundled binary.
Resolution order is
imageio-ffmpeg(which itself honors theIMAGEIO_FFMPEG_EXEenv var, then its bundled static binary, then the systemPATH) and finally a barePATHlookup. This is what lets subprocess-ffmpeg features work on a machine where onlypip installran —imageio-ffmpegis a moviepy dependency, so it is present wherever mixing’s video stack is.- Raises:
RuntimeError – when no ffmpeg executable can be found, naming both remedies (installing
imageio-ffmpegor a system ffmpeg).- Return type:
>>> isinstance(ffmpeg_exe(), str) True
- mixing.util.get_path_from_clipboard()[source]¶
Get file path from clipboard and validate it.
Intelligently extracts file paths from various clipboard contents including:
Direct file paths
File paths within error messages or tracebacks
Quoted paths
- Return type:
- mixing.util.has_ffmpeg()[source]¶
Return True if the
ffmpegbinary is available onPATH.Most real video work in
mixing(concatenation, trim/pad, dimension normalization, audio replacement) shells out to ffmpeg via moviepy. Without it, some operations degrade silently — producing wrong-duration or lower-quality output instead of failing. Callers should check this at startup and refuse to run rather than emit broken media.>>> isinstance(has_ffmpeg(), bool) True- Return type:
- mixing.util.require_media_extra(feature, *, modules=('numpy', 'pydub', 'scipy', 'moviepy', 'cv2', 'PIL', 'burns', 'looks'))[source]¶
Raise an informative
ImportErrorif themediaextra is not installed.The base
pip install mixingships only the pure modules (srt,chapters,errors,util,egress,transcript, TTS); the moviepy / opencv / scipy / pydub backends come withmixing[media].>>> require_media_extra("demo", modules=("math",)) >>> require_media_extra("demo", modules=("no_such_module_xyz",)) Traceback (most recent call last): ... ImportError: demo requires the 'media' extra ...
- mixing.util.require_ml_extra(feature, *, modules=('torch', 'transformers'))[source]¶
Raise an informative
ImportErrorif themlextra is not installed.torch/transformers(the pretrained AudioSet tagger) come withmixing[ml]; nothing imports them until a learned feature is used.>>> require_ml_extra("demo", modules=("math",)) >>> require_ml_extra("demo", modules=("no_such_module_xyz",)) Traceback (most recent call last): ... ImportError: demo requires the 'ml' extra ...
- mixing.util.require_package(package_name)[source]¶
Import a package, raising an informative error if not installed.
Packages supplied by the
mediaormlextra get a hint naming that extra.>>> math = require_package('math') >>> math.pi 3.141592653589793
- mixing.util.to_seconds(value, *, unit, rate)[source]¶
Convert time value to seconds based on unit.
- Parameters:
- Return type:
- Returns:
Time in seconds
Examples
>>> to_seconds(10, unit="seconds", rate=24) 10.0 >>> to_seconds(240, unit="frames", rate=24) 10.0 >>> to_seconds(10000, unit="milliseconds", rate=24) 10.0