[PHP] duration of mp3 file

2007-07-11 Thread Steven Macintyre
Allow bunnies ...

Any takers on this ... I JUST want the duration of the mp3 file - with a
small function if possible ... I honestly don't want to use a class like
http://www.phpclasses.org/browse/package/112.html

The coding is terrible and SERIOUSLY over inflated for what I want.

Anyone know of a simple class / function ?

S

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] duration of mp3 file

2007-07-11 Thread Jim Moseby
 
 Allow bunnies ...
 
 Any takers on this ... I JUST want the duration of the mp3 
 file - with a
 small function if possible ... I honestly don't want to use a 
 class like
 http://www.phpclasses.org/browse/package/112.html
 
 The coding is terrible and SERIOUSLY over inflated for what I want.
 
 Anyone know of a simple class / function ?
 
 S
 

Apparently, you can read the header of the file to find the bitrate, then
calculate the approximate play duration from that info and the filesize.
Here is information on the mp3 file format:

http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm

...and here is a discussion thread that provides the calculation and other
links:

http://www.hydrogenaudio.org/forums/lofiversion/index.php/t46563.html

I've never done this, and apparently there is an issue with MP3s that have
variable bitrates, but maybe this will get you started in the right
direction.

HTH - JM -- not anything like a bunny ;-)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] duration of mp3 file

2007-07-11 Thread Steven Macintyre
Shyte ... 

The files are VBR ... I will read up and when I find answer - will revert to
list with it as well..

Ps. 

Everyone is a bunny to me :P

S

 -Original Message-
 From: Jim Moseby [mailto:[EMAIL PROTECTED]
 Sent: 11 July 2007 03:55 PM
 To: 'Steven Macintyre'; php-general@lists.php.net
 Subject: RE: [PHP] duration of mp3 file
 
 
  Allow bunnies ...
 
  Any takers on this ... I JUST want the duration of the mp3
  file - with a
  small function if possible ... I honestly don't want to use a
  class like
  http://www.phpclasses.org/browse/package/112.html
 
  The coding is terrible and SERIOUSLY over inflated for what I
 want.
 
  Anyone know of a simple class / function ?
 
  S
 
 
 Apparently, you can read the header of the file to find the
 bitrate, then
 calculate the approximate play duration from that info and the
 filesize.
 Here is information on the mp3 file format:
 
 http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm
 
 ...and here is a discussion thread that provides the calculation
 and other
 links:
 
 http://www.hydrogenaudio.org/forums/lofiversion/index.php/t46563.ht
 ml
 
 I've never done this, and apparently there is an issue with MP3s
 that have
 variable bitrates, but maybe this will get you started in the right
 direction.
 
 HTH - JM -- not anything like a bunny ;-)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] duration of mp3 file

2007-07-11 Thread Crayon Shin Chan
On Wednesday 11 July 2007 21:32, Steven Macintyre wrote:

 Any takers on this ... I JUST want the duration of the mp3 file - with
 a small function if possible ... I honestly don't want to use a class
 like http://www.phpclasses.org/browse/package/112.html

 The coding is terrible and SERIOUSLY over inflated for what I want.

So why not take the part that you need and rewrite it so that it is not so 
terrible?

-- 
Crayon

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] duration of mp3 file

2007-07-11 Thread Andrei

Or you could use ffmpeg executable to get details about the media file.
You will have to parse the response of the executable.
The only thing is that you must have exec function or an execution
function available and ffmpeg installed.
This is for linux machines tho... Don't know if ffmpeg is available for
windows too.

Andy

Steven Macintyre wrote:
 Shyte ... 

 The files are VBR ... I will read up and when I find answer - will revert to
 list with it as well..

 Ps. 

 Everyone is a bunny to me :P

 S

   
 -Original Message-
 From: Jim Moseby [mailto:[EMAIL PROTECTED]
 Sent: 11 July 2007 03:55 PM
 To: 'Steven Macintyre'; php-general@lists.php.net
 Subject: RE: [PHP] duration of mp3 file

 
 Allow bunnies ...

 Any takers on this ... I JUST want the duration of the mp3
 file - with a
 small function if possible ... I honestly don't want to use a
 class like
 http://www.phpclasses.org/browse/package/112.html

 The coding is terrible and SERIOUSLY over inflated for what I
   
 want.
 
 Anyone know of a simple class / function ?

 S

   
 Apparently, you can read the header of the file to find the
 bitrate, then
 calculate the approximate play duration from that info and the
 filesize.
 Here is information on the mp3 file format:

 http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm

 ...and here is a discussion thread that provides the calculation
 and other
 links:

 http://www.hydrogenaudio.org/forums/lofiversion/index.php/t46563.ht
 ml

 I've never done this, and apparently there is an issue with MP3s
 that have
 variable bitrates, but maybe this will get you started in the right
 direction.

 HTH - JM -- not anything like a bunny ;-)
 

   


RE: [PHP] duration of mp3 file

2007-07-11 Thread Polonkai Gergely
Or you can use sox, if you compile it with mp3 support. It works for me...

-Original Message-
From: Andrei [EMAIL PROTECTED]
To: 'Jim Moseby' [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: 07. 07. 11. 16:25
Subject: Re: [PHP] duration of mp3 file


Or you could use ffmpeg executable to get details about the media file.
You will have to parse the response of the executable.
The only thing is that you must have exec function or an execution
function available and ffmpeg installed.
This is for linux machines tho... Don't know if ffmpeg is available for
windows too.

Andy

Steven Macintyre wrote:
 Shyte ... 

 The files are VBR ... I will read up and when I find answer - will revert to
 list with it as well..

 Ps. 

 Everyone is a bunny to me :P

 S

   
 -Original Message-
 From: Jim Moseby [mailto:[EMAIL PROTECTED]
 Sent: 11 July 2007 03:55 PM
 To: 'Steven Macintyre'; php-general@lists.php.net
 Subject: RE: [PHP] duration of mp3 file

 
 Allow bunnies ...

 Any takers on this ... I JUST want the duration of the mp3
 file - with a
 small function if possible ... I honestly don't want to use a
 class like
 http://www.phpclasses.org/browse/package/112.html

 The coding is terrible and SERIOUSLY over inflated for what I
   
 want.
 
 Anyone know of a simple class / function ?

 S

   
 Apparently, you can read the header of the file to find the
 bitrate, then
 calculate the approximate play duration from that info and the
 filesize.
 Here is information on the mp3 file format:

 http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm

 ...and here is a discussion thread that provides the calculation
 and other
 links:

 http://www.hydrogenaudio.org/forums/lofiversion/index.php/t46563.ht
 ml

 I've never done this, and apparently there is an issue with MP3s
 that have
 variable bitrates, but maybe this will get you started in the right
 direction.

 HTH - JM -- not anything like a bunny ;-)
 

   

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] duration of mp3 file

2007-07-11 Thread Olav Mørkrid

http://arrozcru.no-ip.org/ffmpeg_builds/

On 11/07/07, Andrei [EMAIL PROTECTED] wrote:


Or you could use ffmpeg executable to get details about the media file.
You will have to parse the response of the executable.
The only thing is that you must have exec function or an execution
function available and ffmpeg installed.
This is for linux machines tho... Don't know if ffmpeg is available for
windows too.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] duration of mp3 file

2007-07-11 Thread Richard Lynch
On Wed, July 11, 2007 8:32 am, Steven Macintyre wrote:
 Allow bunnies ...

 Any takers on this ... I JUST want the duration of the mp3 file - with
 a
 small function if possible ... I honestly don't want to use a class
 like
 http://www.phpclasses.org/browse/package/112.html

 The coding is terrible and SERIOUSLY over inflated for what I want.

 Anyone know of a simple class / function ?

id3_lib and/or the PHP ID3 project may or may not let you pull the
duration out of the early frames of the MP3...

Though those are also quite a bit over-inflated for what you want...

If all else fails, and if a reasonable margin of error is acceptable...

A CRUDE hack to get an estimate, if you know in advance that all the
files are a certain audio quality, is to just divide the filesize by
some factor that's an average of the ratio between duration/filesize
of some known sample files...

I often eyeball an MP3 filesize in the shell and can tell you to
within a few seconds how long it is, just based on filesize, as they
are all stereo 128K, at least in my collection.

Except the ones named lofi which are mono 64K, and that's a different
ratio is all :-)

The point being that if it's just eye candy to tell the user how long
the thing is, you don't NEED microsecond accuracy anyway, just do
something like:

//very crude estimate, if I did the math in my head right...
$ratio = 6000; //128K, stereo, a meg a minute, give or take...
$filesize = filesize($mp3);
$duration = $filesize / $ratio;
$minutes = floor($duration / 60);
$seconds = $duration - ($minutes * 60);
echo $minutes:$seconds minutes;

Sometimes we programmers get so wrapped up in perfection and detail
work, we ignore a seemingly overly simplistic solution, to our
detriment.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php