PHP获取音频mp3文件时长或音频文件其它参数属性

今天在开发项目中遇到一个问题,要获取到上传音频的时长,从而展示在前端页面

最后找到解决方案:

1、首先,我们需要先下载一份PHP类—getid3    https://codeload.github.com/JamesHeinrich/getID3/zip/master

2、解压文件,把整个文件夹上传到服务器

3、贴代码

  include_once ‘getid3/getid3.php‘; //引入该文件

  $getID3 = new getID3(); //实例化类
  $ThisFileInfo = @$getID3->analyze($path); //分析文件,$path为音频文件的地址
  $fileduration= $ThisFileInfo[‘playtime_seconds‘]; //这个获得的便是音频文件的时长

4.大功告成,直接把获取到 时长$fileduration 插入数据库

原文地址:https://www.cnblogs.com/huoshantian/p/9845242.html

时间: 2024-07-30 00:32:50

PHP获取音频mp3文件时长或音频文件其它参数属性的相关文章

asp.net 获取mp3 播放时长

1 Shell32 //添加引用:COM组件的Microsoft Shell Controls And Automation //然后引用 using Shell32; //如果出现"无法嵌入互操作类型 请改用适用的接口"报错----修改引用里面的shell32属性嵌入互操作类型改为false public static string GetMP3FileDurationAll(string fileName) { ShellClass sh = new ShellClass(); F

java 处理获取视频文件时长

现在所做的项目需要获取视频的时长.因为jdk1.5的api没看到有这个方法.所以在网上找了一下,发现jave这个项目.Encoder这个类有个方法: MulitimediaInfo中有个getDuration() 这便是我要找的答案 试验代码加上 因为返回的为毫秒,实际情况需要转换.

获取音、视频时长(NAudio,Shell32,FFmpeg)

参考网址:https://blog.csdn.net/u013810234/article/details/57471780 以下为本次测试用到的音.视频格式: audio :".wav;.mp3;.wma;.ra;.mid;.ogg;.ape;.au;.aac;"; vedio :".mp4;.mpg;.mpeg;.avi;.rm;.rmvb;.wmv;.3gp;.flv;.mkv;.swf;.asf;"; Note: 1. 测试音.视频均为对应格式的有效文件(下

java读取视频文件时长

1.下载jar包:http://www.sauronsoftware.it/projects/jave/index.php 2.上代码 1 @RequestMapping(value = "amendFile.htm", produces = "application/json;charset=UTF-8") 2 @ResponseBody 3 public String amendFile(MultipartFile file, HttpServletReques

选择本地视频时获取视频分辨率和时长

< video style = "display:none;" controls = "controls" id = "aa" > </video> <input type = "file" onchange = "changeFile(this)" > <script> function myFunction(ele) { //视频时长  单位秒 alert

Linux下,拷贝文件时,排除某些文件

一下是自己用到到几次实践,觉得很赞: 1.拷贝文件时,排除某些不需要的文件: 1)使用xargs来做: ls /tmp/test/ |grep -v .gz |xargs -i cp -r /tmp/test/{} /tmp/test_cp 2)使用find+cpio的方式: find /tmp/test/ |grep -v .gz |cpio -pdm /tmp/test_cp/ 3) 使用rsync来做: rsync -avp --exclude = /tmp/test/xxx  /tmp/

7z压缩文件时排除指定的文件

分享一个7z压缩文件时排除指定文件类型的命令行,感觉很有用: 7z a -t7z d:\updateCRM.7z d:\updateCRM\*.* -r -x!*.log -x!*bak a:创建压缩文件 -t7z:7z格式 d:\updateCRM.7z 目标文件名 d:\update7z\*.* 源文件位置 -r:遍历所有子目录 -x!* 要扣除的文件类型

java获取mp3的时长和播放mp3文件

所需包为jaudiotagger-2.2.6-SNAPSHOT.jar和jl1.0.1.jar. import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import org.jaudiotagger.audio.AudioFileIO; import org.jaudiotagger.audio.mp3.MP3AudioHeader; import org.jaudiota

[原]通过配合ffmpeg.exe获取视频文件时长

import subprocess import os import time def getTime(flvpath,fid): #file_str = '1.flv' file_str = flvpath wg = subprocess.Popen(['ffmpeg.exe', '-i', file_str], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) (standardout, junk) = wg.communicate() an