Home >php教程 >php手册 >php 获取音频文件时长

php 获取音频文件时长

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 19:35:213028browse

getID3()是从MP3等媒体文件中提取文件信息的php类,既可以提取也能修改文件的标签信息。它能读取的文件类型非常多,例如MP3、wav等.示例官方下载地址:http://sourceforge.net/projects/getid3/files/ 无 ?phpinclude "getid3/getid3.php";$fileUrl = "11471.m

getID3() 是从MP3等媒体文件中提取文件信息的php类,既可以提取也能修改文件的标签信息。它能读取的文件类型非常多,例如MP3、wav等. 示例官方下载地址:http://sourceforge.net/projects/getid3/files/ 
<?php
	include "getid3/getid3.php";
	
	$fileUrl = "11471.mp3";
	$getID3 = new getID3();    //实例化类

	$ThisFileInfo = $getID3->analyze("11471.mp3");	//分析文件
	$time = $ThisFileInfo['playtime_seconds'];	    //获取mp3的长度信息
	echo $ThisFileInfo['playtime_seconds'];         //获取MP3文件时长
?>
/*使用这个不是很精确。*/
function get_duration($file,$rate=128){
  if(!$file)return ;
  return  ceil(((filesize($file)/1024)/$rate)*8);
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn