Skip to content

types

Chapter = tuple[timedelta | int, Optional[str]] module-attribute

PathLike = Union[Path, str, None] module-attribute

Paths = Union[PathLike, list[PathLike]] module-attribute

Trim = tuple[int | None, int | None] module-attribute

__all__ = ['PathLike', 'Paths', 'Trim', 'TrackType', 'AudioFormat', 'AudioFrame', 'AudioStats', 'AudioInfo', 'Chapter', 'DitherType', 'LossyWavQuality'] module-attribute

AudioFormat dataclass

Source code in muxtools/utils/types.py
@dataclass
class AudioFormat:
    format: str
    ext: str
    codecid: str
    lossy: bool = True

codecid: str instance-attribute

ext: str instance-attribute

format: str instance-attribute

lossy: bool = True class-attribute instance-attribute

__init__

AudioFrame dataclass

A dataclass representing ffmpeg's ashowdata filter output.

Parameters:

Name Type Description Default
n int

The (sequential) number of the input frame, starting from 0

required
pts int

The presentation timestamp of the input frame, in time base units the time base depends on the filter input pad, and is usually 1/sample_rate

required
pts_time float

The presentation timestamp of the input frame in seconds

required
num_samples int

Number of samples in a frame (can also be refered to as frame length or size)

required
Source code in muxtools/utils/types.py
@dataclass
class AudioFrame:
    """
    A dataclass representing ffmpeg's `ashowdata` filter output.

    :param n:           The (sequential) number of the input frame, starting from 0
    :param pts:         The presentation timestamp of the input frame, in time base units
                        the time base depends on the filter input pad, and is usually 1/sample_rate

    :param pts_time:    The presentation timestamp of the input frame in seconds
    :param num_samples: Number of samples in a frame (can also be refered to as frame length or size)
    """

    n: int
    pts: int
    pts_time: float
    num_samples: int

n: int instance-attribute

num_samples: int instance-attribute

pts: int instance-attribute

pts_time: float instance-attribute

__init__

AudioInfo dataclass

Source code in muxtools/utils/types.py
@dataclass
class AudioInfo:
    stats: AudioStats = None
    frames: list[AudioFrame] | None = None

    def num_samples(self) -> int:
        for frame in self.frames:
            if frame.num_samples:
                return frame.num_samples

frames: list[AudioFrame] | None = None class-attribute instance-attribute

stats: AudioStats = None class-attribute instance-attribute

__init__

num_samples

Source code in muxtools/utils/types.py
def num_samples(self) -> int:
    for frame in self.frames:
        if frame.num_samples:
            return frame.num_samples

AudioStats dataclass

A dataclass representing ffmpeg's astats filter output.

Too many attributes to document to be honest.

See https://ffmpeg.org/ffmpeg-filters.html#astats-1

Source code in muxtools/utils/types.py
@dataclass
class AudioStats:
    """
    A dataclass representing ffmpeg's `astats` filter output.

    Too many attributes to document to be honest.

    See https://ffmpeg.org/ffmpeg-filters.html#astats-1
    """

    dc_offset: float = 0.0
    min_level: float = 0.0
    max_level: float = 0.0
    min_difference: float = 0.0
    max_difference: float = 0.0
    mean_difference: float = 0.0
    rms_difference: float = 0.0
    peak_level_db: float = 0.0
    rms_level_db: float = 0.0
    rms_peak_db: float = 0.0
    rms_trough_db: float = 0.0
    flat_factor: float = 0.0
    peak_count: float = 0.0
    noise_floor_db: float = 0.0
    noise_floor_count: float = 0.0
    entropy: float = 0.0
    bit_depth: str = ""
    number_of_samples: int = 0

bit_depth: str = '' class-attribute instance-attribute

dc_offset: float = 0.0 class-attribute instance-attribute

entropy: float = 0.0 class-attribute instance-attribute

flat_factor: float = 0.0 class-attribute instance-attribute

max_difference: float = 0.0 class-attribute instance-attribute

max_level: float = 0.0 class-attribute instance-attribute

mean_difference: float = 0.0 class-attribute instance-attribute

min_difference: float = 0.0 class-attribute instance-attribute

min_level: float = 0.0 class-attribute instance-attribute

noise_floor_count: float = 0.0 class-attribute instance-attribute

noise_floor_db: float = 0.0 class-attribute instance-attribute

number_of_samples: int = 0 class-attribute instance-attribute

peak_count: float = 0.0 class-attribute instance-attribute

peak_level_db: float = 0.0 class-attribute instance-attribute

rms_difference: float = 0.0 class-attribute instance-attribute

rms_level_db: float = 0.0 class-attribute instance-attribute

rms_peak_db: float = 0.0 class-attribute instance-attribute

rms_trough_db: float = 0.0 class-attribute instance-attribute

__init__

DitherType

Bases: IntEnum

FFMPEG Dither Methods, see https://ffmpeg.org/ffmpeg-resampler.html#Resampler-Options

Source code in muxtools/utils/types.py
class DitherType(IntEnum):
    """
    FFMPEG Dither Methods, see https://ffmpeg.org/ffmpeg-resampler.html#Resampler-Options
    """

    RECTANGULAR = 1
    TRIANGULAR = 2  # Allegedly SoX's default
    TRIANGULAR_HP = 3
    LIPSHITZ = 4
    SHIBATA = 5  # Foobar uses this for example
    LOW_SHIBATA = 6
    HIGH_SHIBATA = 7
    F_WEIGHTED = 8
    MODIFIED_E_WEIGHTED = 9
    IMPROVED_E_WEIGHTED = 10

F_WEIGHTED = 8 class-attribute instance-attribute

HIGH_SHIBATA = 7 class-attribute instance-attribute

IMPROVED_E_WEIGHTED = 10 class-attribute instance-attribute

LIPSHITZ = 4 class-attribute instance-attribute

LOW_SHIBATA = 6 class-attribute instance-attribute

MODIFIED_E_WEIGHTED = 9 class-attribute instance-attribute

RECTANGULAR = 1 class-attribute instance-attribute

SHIBATA = 5 class-attribute instance-attribute

TRIANGULAR = 2 class-attribute instance-attribute

TRIANGULAR_HP = 3 class-attribute instance-attribute

LossyWavQuality

Bases: IntEnum

LossyWAV Quality presets, see https://wiki.hydrogenaud.io/index.php?title=LossyWAV#Quality_presets

TL;DR: Insane the least lossy, ExtraPortable the most lossy.

Source code in muxtools/utils/types.py
class LossyWavQuality(IntEnum):
    """
    LossyWAV Quality presets, see https://wiki.hydrogenaud.io/index.php?title=LossyWAV#Quality_presets

    TL;DR: Insane the least lossy, ExtraPortable the most lossy.
    """

    INSANE = 1
    EXTREME = 2
    HIGH = 3
    STANDARD = 4
    ECONOMIC = 5
    PORTABLE = 6
    EXTRAPORTABLE = 7

ECONOMIC = 5 class-attribute instance-attribute

EXTRAPORTABLE = 7 class-attribute instance-attribute

EXTREME = 2 class-attribute instance-attribute

HIGH = 3 class-attribute instance-attribute

INSANE = 1 class-attribute instance-attribute

PORTABLE = 6 class-attribute instance-attribute

STANDARD = 4 class-attribute instance-attribute

TrackType

Bases: IntEnum

Source code in muxtools/utils/types.py
class TrackType(IntEnum):
    VIDEO = 1
    AUDIO = 2
    SUB = 3
    ATTACHMENT = 4
    CHAPTERS = 5
    MKV = 6

ATTACHMENT = 4 class-attribute instance-attribute

AUDIO = 2 class-attribute instance-attribute

CHAPTERS = 5 class-attribute instance-attribute

MKV = 6 class-attribute instance-attribute

SUB = 3 class-attribute instance-attribute

VIDEO = 1 class-attribute instance-attribute

ValidInputType

Bases: IntEnum

Source code in muxtools/utils/types.py
class ValidInputType(IntEnum):
    FLAC = 1
    AIFF = 2
    W64 = 3
    RF64 = 4
    AIFF_OR_FLAC = 5
    W64_OR_FLAC = 6
    RF64_OR_FLAC = 7

    def allows_flac(self) -> bool:
        return "_OR_FLAC" in str(self.name)

    def remove_flac(self):
        match self:
            case ValidInputType.AIFF_OR_FLAC:
                return ValidInputType.AIFF
            case ValidInputType.RF64_OR_FLAC:
                return ValidInputType.RF64
            case ValidInputType.W64_OR_FLAC:
                return ValidInputType.W64

        return ValidInputType.AIFF

AIFF = 2 class-attribute instance-attribute

AIFF_OR_FLAC = 5 class-attribute instance-attribute

FLAC = 1 class-attribute instance-attribute

RF64 = 4 class-attribute instance-attribute

RF64_OR_FLAC = 7 class-attribute instance-attribute

W64 = 3 class-attribute instance-attribute

W64_OR_FLAC = 6 class-attribute instance-attribute

allows_flac

Source code in muxtools/utils/types.py
def allows_flac(self) -> bool:
    return "_OR_FLAC" in str(self.name)

remove_flac

Source code in muxtools/utils/types.py
def remove_flac(self):
    match self:
        case ValidInputType.AIFF_OR_FLAC:
            return ValidInputType.AIFF
        case ValidInputType.RF64_OR_FLAC:
            return ValidInputType.RF64
        case ValidInputType.W64_OR_FLAC:
            return ValidInputType.W64

    return ValidInputType.AIFF

qAAC_MODE

Bases: IntEnum

Source code in muxtools/utils/types.py
class qAAC_MODE(IntEnum):
    TVBR = 1
    CVBR = 2
    ABR = 3
    CBR = 4

ABR = 3 class-attribute instance-attribute

CBR = 4 class-attribute instance-attribute

CVBR = 2 class-attribute instance-attribute

TVBR = 1 class-attribute instance-attribute