PHP 获取视频信息
通过php 获取视频时长
可以使用 getid3 来实现功能
下载地址 https://github.com/JamesHeinrich/getID3
<?php
// 引入 gitid3 包
include_once('./getID3-master/getid3/getid3.php');
// TODO 如果需要获取远程资源信息内容 需要将资源下载到本地
// $path = trim("https://xxxx.xxx.com/xxx.mp4"); // 不可用网络资源路径
// $content = file_get_contents($path);
// file_put_contents("./test.mp4", $content);
$path = "./test.mp4";
$getID3 = new getID3(); // 实例化类
$fileInfo = $getID3->analyze($path); // 分析文件,$path为媒体文件的地址
// TODO $fileInfo 中有很多 媒体文件相关的信息内容 可以打印查看
$fileDuration = $fileInfo['playtime_seconds']; // 获取媒体文件的时长
// 处理业务需求逻辑 ......
?>