[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to find play length of .ogg file using python?



Following up to myself:

On 6/15/06, Michael Marsh <michael.a.marsh@gmail.com> wrote:
On 6/15/06, Marc Shapiro <mshapiro_42@yahoo.com> wrote:
> mns@xander:~/Projects/Python$ ogg123.py --device=oss cues/MayTheWords.ogg
> Module choice: ao
> Playing cues/MayTheWords.ogg
>
> Traceback (most recent call last):
>   File "./ogg123.py", line 221, in ?
>     main()
>   File "./ogg123.py", line 218, in main
>     myplayer.play(file)
>   File "./ogg123.py", line 52, in play
>     self.start(vf)
>   File "./ogg123.py", line 59, in start
>     print vi.__dict__
> AttributeError: No attribute: __dict__
>
> --------------------------------------

Sorry.  __dict__ is class metadata, so that should have been something
along the lines of:

import pyvorbis
print pyvorbis.<class name>.__dict__

I don't have pyvorbis at work, so I can't check this myself right now.

I've poked around with ogg.vorbis, and I got the following:

import ogg.vorbis
a = ogg.vorbis.VorbisFile('./music/t_o_p/track01.cdda.ogg')
print a.__methods__
['bitrate', 'bitrate_instant', 'comment', 'info', 'pcm_seek',
'pcm_seek_page', 'pcm_tell', 'pcm_total', 'raw_seek', 'raw_tell',
'raw_total', 'read', 'seekable', 'serialnumber', 'streams',
'time_seek', 'time_seek_page', 'time_tell', 'time_total']
print a.time_total(0)
299.466666667
print a.time_total(0) / 60
4.99111111111

This track is, according to ogg123, just a hair under 5 minutes.  I
have no idea what the argument to time_total is supposed to mean, but
it has to be a non-positive integer, apparently.  All negative
integers I tried yield the same result as 0.

--
Michael A. Marsh
http://www.umiacs.umd.edu/~mmarsh
http://mamarsh.blogspot.com



Reply to: