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

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



Michael Marsh wrote:

On 6/15/06, Marc Shapiro <mshapiro_42@yahoo.com> wrote:

Digby Tarvin wrote:
>I would take a look at the source for the 'ogginfo' command, or if
>performance is not important, just parse its output:
I am hoping for a pure python method of doing this, so parsing the
output of ogginfo is not my prefered method, but it DOES work.

I have not had a chance to sort through the source for ogginfo, and
doing so does not thrill me, but it may give me a hint what the
attribute names might be for python-pyvorbis, thereby allowing me to
stick to a python solution.


Have you tried printing out __dict__ for the object returned by
VorbisFile.info()?

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__

--------------------------------------

Also, looking through the source for ogginfo, it appears that the time may not be a direct attribute of the info object. Ogginfo seems to be getting a 'lastgranulepos' (which must be a frame position?) from the data stream and dividing it by the rate from the info object to get the time. I have no idea how to get this unless pyvorbis provides it, but simply does not document the fact. Very little, in fact, seems to be documented.

--
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



Reply to: