如何使用getID3获取长度视频



我会用php和getID3库从我的文件视频中获取长度视频,我的视频长度是00:02:03,但这个输出是02:03:00,我如何更改

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'];
}
// 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;
    }
}

相关内容

  • 没有找到相关文章

最新更新