mp3 file duration being set to 39:60

Joined:Thu Apr 19, 2012 4:27 am
Are you a spambot?:no
mp3 file duration being set to 39:60

Post by shi99 » Thu Apr 19, 2012 5:00 am


We have a Drupal site that creates and RSS feed for itunes using the views_rss_itunes module. This module uses the getid3 library to get file information and use it in the feed.
If all works great but we have noticed that one mp3 file ends up with a duration of 39:60 which raises an error since it has 60 seconds.

Since we needed to resolve the issue, for now we made a change to the getid3.lib.php on line 449.
In the original line of code the seconds are being rounded so we got the duration of 39:60

Code: Select all

$S = round( $seconds - (3600 * $H) - (60 * $M)        );
We changed this to floor the seconds instead so we get the duration 39:59

Code: Select all

$S = floor( $seconds - (3600 * $H) - (60 * $M)        );
We are not sure if this is the best location to make the change or if it should be set somewhere else like the file.
But we wanted to let you know in case anybody else was having the same issue. If it is not recommended to make the change we did we would be grateful to hear better options.


James Heinrich
getID3() v1 developer
Joined:Fri May 04, 2001 4:00 pm
Are you a spambot?:no
Location:Northern Ontario, Canada

Re: mp3 file duration being set to 39:60

Post by James Heinrich » Thu Apr 19, 2012 12:56 pm

Issue confirmed.
The better solution is to change 3 lines above that:

Code: Select all

//$seconds = abs($seconds);
$seconds = round(abs($seconds));
Rounding the seconds first before calculating the breakdown of H/M/S eliminates the problem.

Now your duration of 2399.6 seconds will display as 40:00 instead of 39:60 (as before) or 39:59 (your solution).

Fixed in v1.9.4