Page 1 of 1

convert size to length

Posted: Sat Dec 09, 2006 6:29 am
by chitara
Hi guys!!

can anyone please tell me how to convert a audio file size to length.
Say I have a file(abc.mpeg) which is 4.6 MB in size & its length is 4.58 minutes.
So is there any function in php by which i can get the length from the size of that file??

maybe the sound is so silly but please help me!!


Regards

Posted: Sat Dec 09, 2006 7:23 am
by feyd
Size rarely has much to do with length because of the various quality levels one can choose when encoding a file. It is best to read the file's data to determine actual length. If you want to throw out an estimate based on an assumption that it is X encoding, then sure. There is no function built into PHP that will do it in a single step for you. You will need to perform that math.

If you want it to be accurate, look into ffmpeg.

convert size to length

Posted: Sat Dec 09, 2006 9:18 pm
by chitara
actually I need to get the length or play-time of each song.

I kept the file into a foleder & there name is in the database.

Can anyone know any way to get the length of music file???

Please tell me.

Posted: Sun Dec 10, 2006 3:03 am
by feyd
I told you how.