如何在 PHP 中获取视频时长、尺寸和大小? [英] How to get video duration, dimension and size in PHP?

查看:41
本文介绍了如何在 PHP 中获取视频时长、尺寸和大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在PHP中获取上传视频文件的时长、尺寸和大小.该文件可以是任何视频格式.

I want to know how to get the duration, dimension and size of uploaded video file in PHP. The file can be in any video format.

推荐答案

getID3 支持视频格式.请参阅:http://getid3.sourceforge.net/

getID3 supports video formats. See: http://getid3.sourceforge.net/

所以,在代码格式中,就像:

So, in code format, that'd be like:

include_once('pathto/getid3.php');
$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 类,然后才能使用!见上面的链接.

Note: You must include the getID3 classes before this will work! See the above link.

如果您有能力修改服务器上的 PHP 安装,那么为此目的的 PHP 扩展是 ffmpeg-php.请参阅:http://ffmpeg-php.sourceforge.net/

If you have the ability to modify the PHP installation on your server, a PHP extension for this purpose is ffmpeg-php. See: http://ffmpeg-php.sourceforge.net/

这篇关于如何在 PHP 中获取视频时长、尺寸和大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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