preprocess
__all__ = ['Resample', 'Loudnorm', 'Downmix', 'Pan', 'CustomPreprocessor']
module-attribute
Pan = Downmix
module-attribute
Preprocessor
Bases: ABC
Source code in muxtools/audio/preprocess.py
refresh_metadata = False
class-attribute
instance-attribute
get_filter(caller=None)
get_args(caller=None)
analyze(file)
Resample
dataclass
Bases: Preprocessor
A FFMPEG Resampling preprocessor. This is used to dither down to 16 bit and resample to 48kHz by default. Uses the sox resampler internally for best results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dither
|
DitherType
|
The dither algorithm to use. Uses SoX's default by default. |
TRIANGULAR
|
depth
|
int | None
|
The bitdepth to dither to. |
16
|
sample_rate
|
int
|
The sample rate to resample to. Defaults to 48kHz because most encoders support it. |
48000
|
Source code in muxtools/audio/preprocess.py
dither: DitherType = DitherType.TRIANGULAR
class-attribute
instance-attribute
depth: int | None = 16
class-attribute
instance-attribute
sample_rate: int = 48000
class-attribute
instance-attribute
refresh_metadata = True
class-attribute
instance-attribute
__init__(dither=DitherType.TRIANGULAR, depth=16, sample_rate=48000)
can_run(track, preprocessors)
Source code in muxtools/audio/preprocess.py
get_args(caller=None)
Source code in muxtools/audio/preprocess.py
classproperty
Bases: object
Source code in muxtools/audio/preprocess.py
Downmix
dataclass
Bases: Preprocessor
A FFMPEG downmixing/pan preprocessor. This essentially just uses the pan filter and offers a few presets.
If you're looking for explanations or other infos feel free to read these threads: https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg https://github.com/mpv-player/mpv/issues/6343
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mixing
|
str | None
|
The Pan filter string. Defaults to the Dave_750 preset. Honestly no recommendations here. Try them all and use what you prefer. |
None
|
force
|
bool
|
Force processing even if there are only 2 channels. |
False
|
Source code in muxtools/audio/preprocess.py
mixing: str | None = None
class-attribute
instance-attribute
force: bool = False
class-attribute
instance-attribute
refresh_metadata = True
class-attribute
instance-attribute
__init__(mixing=None, force=False)
can_run(track, preprocessors)
get_filter(caller=None)
ATSC()
Collier()
Dave_750()
Loudnorm
dataclass
Bases: Preprocessor
A FFMPEG normalization preprocessor according to EBU-R128 standards.
It's strongly recommended to also put a Resample
preprocessor into the chain as this filter needs to upsample to 192kHz and we don't want to encode that after.
This will do a dynamic pass first to measure various values and then do the proper pass so it might take a while.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
i
|
float
|
The integrated loudness target. Range is |
-24.0
|
lra
|
float
|
The loudness range target. Range is |
7.0
|
tp
|
float
|
The maximum true peak. Range is |
-2.0
|
offset
|
float | None
|
Offset gain. Gain is applied before the true-peak limiter. Will be taken from the analysis in the first pass if None. |
None
|
Source code in muxtools/audio/preprocess.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
i: float = -24.0
class-attribute
instance-attribute
lra: float = 7.0
class-attribute
instance-attribute
tp: float = -2.0
class-attribute
instance-attribute
offset: float | None = None
class-attribute
instance-attribute
Measurements
dataclass
Source code in muxtools/audio/preprocess.py
i: float
instance-attribute
lra: float
instance-attribute
tp: float
instance-attribute
thresh: float
instance-attribute
target_offset: float
instance-attribute
__init__(i, lra, tp, thresh, target_offset)
__init__(i=-24.0, lra=7.0, tp=-2.0, offset=None)
can_run(track, preprocessors)
analyze(file)
Source code in muxtools/audio/preprocess.py
get_filter(caller=None)
Source code in muxtools/audio/preprocess.py
CustomPreprocessor
dataclass
Bases: Preprocessor
A custom preprocessor class to pass arbitrary filters or arguments to ffmpeg.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filt
|
str | None
|
Audio filter to append to the filterchain. Don't include any flags or whatever. It should look like this |
None
|
args
|
str | Sequence[str] | None
|
Other args you may want to pass to ffmpeg. |
None
|