rondog Posted July 8, 2008 Share Posted July 8, 2008 I am getting the duration of an FLV through FFMPEG/FFMPEG PHP. I made a function that returns the duration in minutes, however, I have noticed my clips that land right on 2:00, show up as 1:00. I cant figure out why. If its 2:20, it shows up properly as 2:20..It just seems to be a problem when it lands on the 0th second of a minute. Can anyone maybe shed some light? <?php //the duration function function getDur($src) { $mov = new ffmpeg_movie($src,false); $duration = $mov->getDuration(); $duration = round($duration); if($duration == "60") { $min = "1"; } else { $min = ceil($duration / 60) - 1; } $sec = $duration % 60; if(strlen($sec) == "1") { $sec = "0".$sec; } $duration = "$min:$sec"; return $duration; } //where I call the duration while($row = mysql_fetch_array($result)) { $duration = getDur("videos/".$row['filename']); echo $duration; } //etc etc... ?> Link to comment https://forums.phpfreaks.com/topic/113777-solved-getduration-problem/ Share on other sites More sharing options...
Tchelo Posted July 8, 2008 Share Posted July 8, 2008 Well, assuming you have 120 seconds: $min = ceil(120/60) - 1; //$min = 2 - 1 = 1; Link to comment https://forums.phpfreaks.com/topic/113777-solved-getduration-problem/#findComment-584721 Share on other sites More sharing options...
rondog Posted July 8, 2008 Author Share Posted July 8, 2008 I found my old post from this and barrand posted a solution after I checked topic solved and I never saw it. This one seems to be working out so far: <?php function getDur($src) { $mov = new ffmpeg_movie($src,false); $duration = $mov->getDuration(); $duration = round($duration); $mins = sprintf('%d:%02d', $duration/60, $duration % 60); return $mins; } Link to comment https://forums.phpfreaks.com/topic/113777-solved-getduration-problem/#findComment-584820 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.