Digby Tarvin wrote:
On Wed, Jun 14, 2006 at 11:19:08AM -0700, Marc Shapiro wrote:
I am writing a program using pygame to play musical sound cues. I need
a way to determine the play length of a sound file. I can get the
length of .mp3 files with python-pymad. I have also installed
python-pyogg and python-pyvorbis. It seems that I should be able to get
the length of .ogg files with one of these packages, but the
documentation and examples do not show how.
I have googled for these packages and basically have found that
documentation does not seem to exist, yet. It was suggesated to check
the docs for libvorbis, but I haven't been able to find this, either.
The output of VorbisFile.info() seems to be an object with various
attributes, probably including the play length, but the only attributes
shown in the example are channels and rate. The module is a .so file,
so I can not look at python source to determine the other attributes and
I would rather not have to download C source code and plow through
that. Is there a list of the attributes for this object, somewhere?
Can anyone give me an easy way to find the play length of an .ogg file,
or point me to where the documentation exists.
I would take a look at the source for the 'ogginfo' command, or if
performance is not important, just parse its output:
[EMAIL PROTECTED]:/home/digbyt> ogginfo /home/digbyt/work2/...
filename=/home/digbyt/work2/localize/testdata/alphabet.ogg
header_integrity=pass
stream_integrity=pass
file_truncated=false
version=0
channels=1
bitrate_upper=-1000
bitrate_nominal=128000
bitrate_lower=-1000
bitrate_average=84458
length=59.443084
playtime=0:59
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.
Has anyone else come across this, who might be able to tell me what the
attribute names are?
Thanks.
--
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]