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 中获取视频时长、尺寸和大小?
基础教程推荐
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何替换eregi() 2022-01-01
