如何获取视频的持续时间,维度和大小在PHP? [英] How to get video duration, dimension and size in PHP?

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

问题描述

我想知道如何在PHP中获取上传的视频文件的持续时间,维度和大小。该文件可以是任何视频格式。

解决方案

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



  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类才能工作!请参阅上述链接。



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


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 supports video formats. See: http://getid3.sourceforge.net/

Edit: 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 />");

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

Edit: 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天全站免登陆