How to get video duration, dimension and size in PHP?(如何在 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 中获取视频时长、尺寸和大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 PHP 中获取视频时长、尺寸和大小?


- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01