0

i would get length video from my file video with php and getID3 library, my video's length is 00:02:03 but this output is 02:03:00, how can i change

move_uploaded_file($source,$direktori); 
$durasi = getDuration($direktori);
$endtime = date('H:i:s', strtotime($durasi));
echo $endtime;

function getDuration($file){
include_once("getID3/getid3/getid3.php");
$getID3 = new getID3;
$file = $getID3->analyze($file);
return $file['playtime_string'];

}

1 Answers1

0
// Using getid3 library, get duration
function get_duration($filename){

    $getID3 = new getID3;

    $file = $getID3->analyze($filename);

    $duration_string = $file['playtime_string'];

    // Format string to be 00:00:00
    return format_duration($duration_string);
}

// Format to AA::BB:CC
function format_duration($duration){

    // The base case is A:BB
    if(strlen($duration) == 4){
        return "00:0" . $duration;
    }
    // If AA:BB
    else if(strlen($duration) == 5){
        return "00:" . $duration;
    }   // If A:BB:CC
    else if(strlen($duration) == 7){
        return "0" . $duration;
    }
}
Bilal Halayqa
  • 932
  • 1
  • 6
  • 25