我想知道如何在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 中获取视频时长、尺寸和大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Zend 中的动作视图助手 - 解决方法?Action View Helper in Zend - Work around?(Zend 中的动作视图助手 - 解决方法?)
这是将 URI 与 PHP 中用于 MVC 的类/方法匹配的好方Is this a good way to match URI to class/method in PHP for MVC(这是将 URI 与 PHP 中用于 MVC 的类/方法匹配的好方法吗)
我在哪里保存 Zend Framework 中的部分(视图),以便Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(视图),以
有一个网站的单一入口点.坏的?好的?没问题?Having a single entry point to a website. Bad? Good? Non-issue?(有一个网站的单一入口点.坏的?好的?没问题?)
MVC + 服务层在 Zend 或 PHP 中常见吗?Is MVC + Service Layer common in zend or PHP?(MVC + 服务层在 Zend 或 PHP 中常见吗?)
PHP MVC 方法中的 Hello World 示例Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)