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


-- 
Digby R. S. Tarvin                                          digbyt(at)digbyt.com
http://www.digbyt.com


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to