Unix Shell - Length of wav file?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > January 2006 > Length of wav file?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Length of wav file?
seguso

2006-01-29, 9:31 pm

Hi,

this may sound as a weird question. :-) Is there a way to know the
duration of a wav file in a Python script? I am trying to write a
program that creates cue files and does other things. Thank you

--
Maurizio Colucci
http://freetennis.sf.net

Kenny McCormack

2006-01-29, 9:31 pm

In article <1138456371.201141.113630@g43g2000cwa.googlegroups.com>,
seguso <maurizio.colucci@gmail.com> wrote:
>Hi,
>
>this may sound as a weird question. :-) Is there a way to know the
>duration of a wav file in a Python script? I am trying to write a
>program that creates cue files and does other things. Thank you


Probably look in comp.lang.python or some such.

Kurt Swanson

2006-01-29, 9:31 pm

"seguso" <maurizio.colucci@gmail.com> writes:
> this may sound as a weird question. :-) Is there a way to know the
> duration of a wav file in a Python script? I am trying to write a
> program that creates cue files and does other things. Thank you


This is quite difficult, as WAV files may have vastly varying
contents. Here is an abbreviated sample of the output of the file
command on WAV files on my system:

RIFF (little-endian) data, WAVE audio, ITU G.711 mu-law, stereo 8000 Hz
RIFF (little-endian) data, WAVE audio, MPEG Layer 3, mono 11025 Hz
RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 11025 Hz
RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 22050 Hz
RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz
RIFF (little-endian) data, WAVE audio, Microsoft PCM, 8 bit, mono 11025 Hz
RIFF (little-endian) data, WAVE audio, Microsoft PCM, 8 bit, mono 11127 Hz
[...]

In all there are 29 different formats in about 600 different WAV files
on my system.

If you could be ensured that all your files of interest would be of
the same type, *and* it is an uncompressed type, you could do a
calculation based upon file size (lopping of the 42 byte WAV header).

Otherwise your best bet would be parsing the output of some sort of
lightweight audio playing or converting program...
--
© 2005 Kurt Swanson AB
seguso

2006-01-30, 8:42 am


seguso wrote:
> Hi,
>
> this may sound as a weird question. :-) Is there a way to know the
> duration of a wav file in a Python script? I am trying to write a
> program that creates cue files and does other things. Thank you
>


I reply to myself:

shninfo len filename

bye

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com