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

php 获取音频文件时长

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:35:21
Original
3012 people have browsed it

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文件时长
?>
Copy after login
/*使用这个不是很精确。*/
function get_duration($file,$rate=128){
  if(!$file)return ;
  return  ceil(((filesize($file)/1024)/$rate)*8);
}
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template