getId3以秒为单位获取视频时长

时间:2018-10-25 19:52:41

标签: php video video-processing duration getid3

如何获取以秒为单位的getId3的playtime_string持续时间?有没有办法在几秒钟内直接获得?不使用其他php函数查看字符串并将其拉出值?

  <?php require_once('getid3/getid3.php');
    $filename='uploads/4thofJuly_184.mp4';
    $getID3 = new getID3;
    $file = $getID3->analyze($filename);
    echo("Duration: ".$file['playtime_string'].
    " / Dimensions: ".$file['video']['resolution_x']." wide by ".$file['video']['resolution_y']." tall".
    " / Filesize: ".$file['filesize']." bytes<br />");
    $getID3 = new getID3;
    $filename='uploads/25PercentOff_710.wmv';
    $file = $getID3->analyze($filename);
    echo("Duration: ".$file['playtime_string'].
    " / Dimensions: ".$file['video']['resolution_x']." wide by ".$file['video']['resolution_y']." tall".
    " / Filesize: ".$file['filesize']." bytes<br />");

    // Calling getimagesize() function 
    $filename="uploads/25PercentOff_960.jpg";
    list($width, $height) = getimagesize($filename); 

    // Displaying dimensions of the image 
    echo "Width of image : " . $width . "<br>"; 

    echo "Height of image : " . $height . "<br>"; 

2 个答案:

答案 0 :(得分:1)

在这种情况下,请使用$file['playtime_seconds'],它将直接为您提供带小数点的秒。您可以根据自己的显示方式使用php的round()floor()函数进行格式化。

答案 1 :(得分:0)

有一个非常简单的答案: 而不是使用$file['playtime_string'] 只需使用:$file['playtime_seconds']