How to get duration of MP3 or wav any audio File in PHP

Today, we will see the way to get duration of mp3 , wav or any audio file in php. Learn more PHP Video File Upload in Server

For this you need to install getID3. Here is the link to download getID3.

Once this downloaded, we can write the below code part to get the duration of a file.

       $filename = 'test.wav';
       $getID3 = new getID3;
       $file = $getID3->analyze($filename);
       $playtime_seconds = $file['playtime_seconds'];
       echo gmdate("H:i:s", $playtime_seconds);

Leave a Reply