Michael Marsh wrote:
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.
Thanks!
That finally did it. Two lines of code, one to open the file and one to
get the run time replace eight lines of opening and reading pipes, then
parsing the output and converting from string to integers then
multiplying and adding. Much simpler this way. I knew that this had to
exist, I just didn't have the expertise to figure out how to find it.
Then end results are identical to what I get from parsing the output of
ogginfo, but this is a pure python solution, which I like much better.
BTW, this method is almost exactly the same as for using pymad to get
the info from an mp3 file. The only differences are the module and
function used to open the file, and in pymad, the function is
total_time(), instead of time_total(0).
--
Marc Shapiro
No boom today. Boom tomorrow. There's always a boom tomorrow.
What?! Look, somebody's got to have some damn perspective around here.
Boom. Sooner or later ... boom!
- Susan Ivanova: B5 - Grail
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]