tags:

views:

42

answers:

3

How I can get the length of an audio file in php.

If it's too hard to do in php then any other way should work alright.

+1  A: 

What kind of audio file? mp3? wav? Anyway you will probably need some specific library. See: http://de.php.net/manual/en/refs.utilspec.audio.php

Radek Suski
mp3, and thanks I'll have a look at that
Belgin Fish
A: 

PHP has no standard audio support, you'll have to recompile PHP yourself, or you can use a tool to get the information:

You could use ffmpeg. Running ffmpeg as follows:

ffmpeg -i someAudio.mp3

will produce this output:

Input #0, mp3, from 'someAudio.mp3':
  Duration: 00:00:34.03, start: 0.000000, bitrate: 127 kb/s
    Stream #0.0: Audio: mp3, 48000 Hz, mono, s16, 128 kb/s

now you'll only need a regexp to parse the result.

Tobias P.
A: 

Lame is a 3rd party application you could consider.

LAME is a high quality MPEG Audio Layer III (MP3) encoder licensed under the LGPL.

Russell Dias