getId3 以秒为单位获取视频时长 [英] getId3 to get video duration in seconds

查看:36
本文介绍了getId3 以秒为单位获取视频时长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何以秒为单位获得 getId3 的 playtime_string 持续时间?有没有几秒钟可以直接到达的地方?不使用其他php函数查看字符串并将其从值中拉出来?

How do i get getId3's playtime_string duration in seconds? Is there away to get directly in seconds? Without using other php functions to look at the string and pull it out of the value?

  <?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>"; 

推荐答案

在这种情况下使用 $file['playtime_seconds'] 它会直接给你带小数点的秒数.您可以使用 php 的 round()floor() 函数对其进行格式化,具体取决于您希望它如何显示.

in this situation use $file['playtime_seconds'] it will give you the seconds directly with a decimal point. Which you can format using php's round() or floor() functions depending on how you want it to display.

这篇关于getId3 以秒为单位获取视频时长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆