How to use the mutagen.StreamInfo function in mutagen

To help you get started, we’ve selected a few mutagen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Source-Python-Dev-Team / Source.Python / addons / source-python / packages / site-packages / mutagen / oggspeex.py View on Github external
from mutagen import StreamInfo
from mutagen._vorbis import VCommentDict
from mutagen.ogg import OggPage, OggFileType, error as OggError
from mutagen._util import cdata, get_size, loadfile, convert_error
from mutagen._tags import PaddingInfo


class error(OggError):
    pass


class OggSpeexHeaderError(error):
    pass


class OggSpeexInfo(StreamInfo):
    """OggSpeexInfo()

    Ogg Speex stream information.

    Attributes:
        length (`float`): file length in seconds, as a float
        channels (`int`): number of channels
        bitrate (`int`): nominal bitrate in bits per second. The reference
            encoder does not set the bitrate; in this case, the bitrate will
            be 0.
    """

    length = 0
    channels = 0
    bitrate = 0
github quodlibet / mutagen / mutagen / ac3.py View on Github external
@enum
class EAC3FrameType(object):
    INDEPENDENT = 0
    DEPENDENT = 1
    AC3_CONVERT = 2
    RESERVED = 3


EAC3_BLOCKS = [1, 2, 3, 6]


class AC3Error(MutagenError):
    pass


class AC3Info(StreamInfo):

    """AC3 stream information.
    The length of the stream is just a guess and might not be correct.

    Attributes:
        channels (`int`): number of audio channels
        length (`float`): file length in seconds, as a float
        sample_rate (`int`): audio sampling rate in Hz
        bitrate (`int`): audio bitrate, in bits per second
        codec (`str`): ac-3 or ec-3 (Enhanced AC-3)
    """

    channels = 0
    length = 0
    sample_rate = 0
    bitrate = 0
github MediaBrowser / plugin.video.emby / resources / lib / libraries / mutagen / oggspeex.py View on Github external
from mutagen import StreamInfo
from mutagen._vorbis import VCommentDict
from mutagen.ogg import OggPage, OggFileType, error as OggError
from mutagen._util import cdata, get_size
from mutagen._tags import PaddingInfo


class error(OggError):
    pass


class OggSpeexHeaderError(error):
    pass


class OggSpeexInfo(StreamInfo):
    """Ogg Speex stream information."""

    length = 0
    """file length in seconds, as a float"""

    channels = 0
    """number of channels"""

    bitrate = 0
    """nominal bitrate in bits per second.

    The reference encoder does not set the bitrate; in this case,
    the bitrate will be 0.
    """

    def __init__(self, fileobj):
github quodlibet / mutagen / mutagen / aiff.py View on Github external
self.delete_chunk(id_)

    def delete_chunk(self, id_):
        """Remove a chunk from the RIFF file"""

        assert_valid_chunk_id(id_)
        self[id_].delete()

    def insert_chunk(self, id_, data=None):
        """Insert a new chunk at the end of the IFF file"""

        assert_valid_chunk_id(id_)
        return self.root.insert_chunk(id_, data)


class AIFFInfo(StreamInfo):
    """AIFFInfo()

    AIFF audio stream information.

    Information is parsed from the COMM chunk of the AIFF file

    Attributes:
        length (`float`): audio length, in seconds
        bitrate (`int`): audio bitrate, in bits per second
        channels (`int`): The number of audio channels
        sample_rate (`int`): audio sample rate, in Hz
        bits_per_sample (`int`): The audio sample size
    """

    length = 0
    bitrate = 0
github rembo10 / headphones / lib / mutagen / m4a.py View on Github external
class M4ATags(DictProxy, Tags):

    def load(self, atoms, fileobj):
        raise error("deprecated")

    def save(self, filename):
        raise error("deprecated")

    def delete(self, filename):
        raise error("deprecated")

    def pprint(self):
        return u""


class M4AInfo(StreamInfo):

    bitrate = 0

    def __init__(self, atoms, fileobj):
        raise error("deprecated")

    def pprint(self):
        return u""


class M4A(FileType):

    _mimes = ["audio/mp4", "audio/x-m4a", "audio/mpeg4", "audio/aac"]

    @loadfile()
    def load(self, filething):
github Source-Python-Dev-Team / Source.Python / addons / source-python / packages / site-packages / mutagen / oggflac.py View on Github external
from mutagen import StreamInfo
from mutagen.flac import StreamInfo as FLACStreamInfo, error as FLACError
from mutagen._vorbis import VCommentDict
from mutagen._util import loadfile, convert_error
from mutagen.ogg import OggPage, OggFileType, error as OggError


class error(OggError):
    pass


class OggFLACHeaderError(error):
    pass


class OggFLACStreamInfo(StreamInfo):
    """OggFLACStreamInfo()

    Ogg FLAC stream info.

    Attributes:
        length (`float`): File length in seconds, as a float
        channels (`float`): Number of channels
        sample_rate (`int`): Sample rate in Hz"
    """

    length = 0
    channels = 0
    sample_rate = 0

    def __init__(self, fileobj):
        page = OggPage(fileobj)
github quodlibet / mutagen / mutagen / wavpack.py View on Github external
version = cdata.ushort_le(header[8:10])
        track_no = ord(header[10:11])
        index_no = ord(header[11:12])
        samples = cdata.uint_le(header[12:16])
        if samples == 2 ** 32 - 1:
            samples = -1
        block_index = cdata.uint_le(header[16:20])
        block_samples = cdata.uint_le(header[20:24])
        flags = cdata.uint_le(header[24:28])
        crc = cdata.uint_le(header[28:32])

        return _WavPackHeader(block_size, version, track_no, index_no,
                              samples, block_index, block_samples, flags, crc)


class WavPackInfo(StreamInfo):
    """WavPack stream information.

    Attributes:
        channels (int): number of audio channels (1 or 2)
        length (float): file length in seconds, as a float
        sample_rate (int): audio sampling rate in Hz
        bits_per_sample (int): audio sample size
        version (int): WavPack stream version
    """

    def __init__(self, fileobj):
        try:
            header = _WavPackHeader.from_fileobj(fileobj)
        except WavPackHeaderError:
            raise WavPackHeaderError("not a WavPack file")
github LordSputnik / mutagen / mutagen / oggtheora.py View on Github external
from mutagen import StreamInfo
from mutagen._vorbis import VCommentDict
from mutagen._util import cdata
from mutagen.ogg import OggPage, OggFileType, error as OggError


class error(OggError):
    pass


class OggTheoraHeaderError(error):
    pass


class OggTheoraInfo(StreamInfo):
    """Ogg Theora stream information.

    Attributes:

    * length - file length in seconds, as a float
    * fps - video frames per second, as a float
    """

    length = 0

    def __init__(self, fileobj):
        page = OggPage(fileobj)
        while not page.packets[0].startswith(b"\x80theora"):
            page = OggPage(fileobj)
        if not page.first:
            raise OggTheoraHeaderError(
github rembo10 / headphones / lib / mutagen / musepack.py View on Github external
return num, i + 1
    if limit > 0:
        raise ValueError
    return 0, 0


def _calc_sv8_gain(gain):
    # 64.82 taken from mpcdec
    return 64.82 - gain / 256.0


def _calc_sv8_peak(peak):
    return (10 ** (peak / (256.0 * 20.0)) / 65535.0)


class MusepackInfo(StreamInfo):
    """MusepackInfo()

    Musepack stream information.

    Attributes:
        channels (`int`): number of audio channels
        length (`float`): file length in seconds, as a float
        sample_rate (`int`): audio sampling rate in Hz
        bitrate (`int`): audio bitrate, in bits per second
        version (`int`) Musepack stream version

    Optional Attributes:

    Attributes:
        title_gain (`float`): Replay Gain for this song
        title_peak (`float`): Peak data for this song
github MediaBrowser / plugin.video.emby / resources / lib / libraries / mutagen / mp4 / __init__.py View on Github external
values = []
        for key, value in sorted(iteritems(self)):
            if not isinstance(key, text_type):
                key = key.decode("latin-1")
            if key == "covr":
                values.append(u"%s=%s" % (key, u", ".join(
                    [u"[%d bytes of data]" % len(data) for data in value])))
            elif isinstance(value, list):
                for v in value:
                    values.append(to_line(key, v))
            else:
                values.append(to_line(key, value))
        return u"\n".join(values)


class MP4Info(StreamInfo):
    """MPEG-4 stream information.

    Attributes:

    * bitrate -- bitrate in bits per second, as an int
    * length -- file length in seconds, as a float
    * channels -- number of audio channels
    * sample_rate -- audio sampling rate in Hz
    * bits_per_sample -- bits per sample
    * codec (string):
        * if starting with ``"mp4a"`` uses an mp4a audio codec
          (see the codec parameter in rfc6381 for details e.g. ``"mp4a.40.2"``)
        * for everything else see a list of possible values at
          http://www.mp4ra.org/codecs.html

        e.g. ``"mp4a"``, ``"alac"``, ``"mp4a.40.2"``, ``"ac-3"`` etc.