Confused about mutagen.flac.StreamInfo

134 views
Skip to first unread message

Rene Maurer

unread,
Apr 21, 2017, 1:48:53 AM4/21/17
to quod-libet-...@googlegroups.com
Hello

I am a little bit confused about the StreamInfo class. Maybe someone
can help me out.

I have....

# soxi 01_donato_lagos_que_sera_vals_1938.flac

Input File : '01_donato_lagos_que_sera_vals_1938.flac'
Channels : 2
Sample Rate : 44100
Precision : 16-bit
Duration : 00:02:26.01 = 6438945 samples = 10950.6 CDDA sectors
File Size : 6.88M
Bit Rate : 377k
Sample Encoding: 16-bit FLAC

# metaflac --show-sample-rate --show-channels --show-bps \
01_donato_lagos_que_sera_vals_1938.flac

44100
2
16

....and I try to get the same information with mutagen:

python2#

>>> import mutragen
>>> mutagen.version
>>> (1, 37)
>>> from mutagen.flac import StreamInfo
>>> info.sample_rate
>>> 443926
>>> info.channels
>>> 4
>>> info.bits_per_sample
>>> 23

Even more strange for me is the following:

>>> import shutil
>>> shutil.copy("01_donato_lagos_que_sera_vals_1938.flac", "x.flac")
>>> info2 = StreamInfo("x.flac")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/mutagen/flac.py", line 109, in
__init__ self.load(data)
File "/usr/lib/python2.7/site-packages/mutagen/flac.py", line 212, in
load self.min_framesize = int(to_int_be(data.read(3)))
File "/usr/lib/python2.7/site-packages/mutagen/flac.py", line 70, in
read size, len(data)))
mutagen.flac.error: file said 3 bytes, read 2 bytes

Any hints?

Best regards
René

Christoph Reiter

unread,
Apr 21, 2017, 3:28:05 AM4/21/17
to Quod Libet Development
On Fri, Apr 21, 2017 at 7:48 AM, Rene Maurer <rene...@gmail.com> wrote:
> Any hints?

The StreamInfo constructor is private and shouldn't be used. Use
mutagen.flac.FLAC("foo.flac").info

Rene Maurer

unread,
Apr 21, 2017, 8:24:29 AM4/21/17
to quod-libet-...@googlegroups.com
Christoph Reiter <reiter.c...@gmail.com> wrote:

> The StreamInfo constructor is private and shouldn't be used. Use
> mutagen.flac.FLAC("foo.flac").info

Thank you very much Christoph for pointing this out.
Reply all
Reply to author
Forward
0 new messages