Media

class audformat.Media(type='other', *, format=None, sampling_rate=None, channels=None, bit_depth=None, video_fps=None, video_resolution=None, video_channels=None, video_depth=None, description=None, meta=None)[source]

Media information.

File format is always converted to lower case.

Parameters
Raises

BadValueError – if an invalid type is passed

Examples

>>> Media(
...     type=define.MediaType.AUDIO,
...     format="wav",
...     sampling_rate=16000,
...     channels=2,
... )
{type: audio, format: wav, channels: 2, sampling_rate: 16000}

__eq__()

Media.__eq__(other)

Return self==value.

Return type

bool

bit_depth

Media.bit_depth

Audio bit depth

channels

Media.channels

Audio channels

description

Media.description

Description

dump()

Media.dump(stream=None, indent=2)

Serialize object to YAML.

Parameters
  • stream – file-like object. If None serializes to string

  • indent (int) – indent

Return type

str

Returns

YAML string

format

Media.format

File format

from_dict()

Media.from_dict(d, ignore_keys=None)

Deserialize object from dictionary.

Parameters
  • d (dict) – dictionary of class variables to assign

  • ignore_keys (Optional[Sequence[str]]) – variables listed here will be ignored

meta

Media.meta

Dictionary with meta fields

sampling_rate

Media.sampling_rate

Audio sampling rate in Hz

to_dict()

Media.to_dict()

Serialize object to dictionary.

Return type

dict

Returns

dictionary with attributes

type

Media.type

Media type

video_channels

Media.video_channels

Video channels per pixel

video_depth

Media.video_depth

Video bit depth

video_fps

Media.video_fps

Video frames per second

video_resolution

Media.video_resolution

Video resolution