Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 正在尝试查找ffmpeg的持续时间_Php_Ffmpeg - Fatal编程技术网

Php 正在尝试查找ffmpeg的持续时间

Php 正在尝试查找ffmpeg的持续时间,php,ffmpeg,Php,Ffmpeg,可能重复: 我目前有以下代码来获取视频持续时间 $file = "videos/the_video.mp4"; passthru("ffmpeg -i ".$file." 2>&1"); $duration = ob_get_contents(); $search='/Duration: (.*?)[.]/'; $duration=preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE); $duration =

可能重复:

我目前有以下代码来获取视频持续时间

$file = "videos/the_video.mp4";
passthru("ffmpeg -i ".$file." 2>&1");
$duration = ob_get_contents();
$search='/Duration: (.*?)[.]/';

$duration=preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE);
$duration = $matches[1][0];

如何使用MP3实现这一点?

如果您想要不使用ffmpeg的解决方案,可以使用getID3:

在此处找到源示例:


感谢您提供此解决方案!
require_once('/path/to/getid3.php'); 

$getID3 = new getID3; 
$filename = "/path/to/mp3"; 

$ThisFileInfo = $getID3->analyze($filename); 
getid3_lib::CopyTagsToComments($ThisFileInfo); 

echo @$ThisFileInfo['playtime_string'];