convert size to length

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chitara
Forum Newbie
Posts: 3
Joined: Thu Nov 23, 2006 5:48 am

convert size to length

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
chitara
Forum Newbie
Posts: 3
Joined: Thu Nov 23, 2006 5:48 am

convert size to length

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I told you how.
Post Reply