我有一个与文件上传相关的问题,我想获得音频文件的持续时间长度以分钟为单位。当我上传这个文件时,我能够得到所有的细节,如大小,类型,最大长度,文件名,但不是音频文件的持续时间。
$config['upload_path'] = './uploads/songs/';
$config['allowed_types'] = 'gif|jpg|png|mov|mp3|aiff|mpeg|zip';
$config['max_size'] = '30000';
$config['max_width'] = '1024';
$config['max_height'] = '1024';
$config['file_ext_tolower'] = 'TRUE';
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
$uploadSong = $this->upload->data();
print_r($uploadSong); 在print_r获得上载文件的输出后
Array ( 
  [file_name] => song_one1.mp3 
  [file_type] => application/octet-stream 
  [file_path] => C:/xampp/htdocs/rockherogame/uploads/songs/         
  [full_path] => C:/xampp/htdocs/rockherogame/uploads/songs/song_one1.mp3 
  [raw_name] => song_one1 
  [orig_name] => song_one.mp3 
  [client_name] => song_one.mp3 
  [file_ext] => .mp3 
  [file_size] => 4059.28 
  [is_image] => 
  [image_width] => 
  [image_height] => 
  [image_type] => 
  [image_size_str] => )请帮助我了解如何获取文件的持续时间?
提前感谢
发布于 2017-01-07 14:29:44
需要计算音频文件的时长。
下面是一个很好的例子,展示了如何在php中做同样的事情。
http://www.zedwood.com/article/127/php-calculate-duration-of-mp3
您还可以安装和使用getid3。代码片段here
发布于 2017-01-07 14:30:11
这应该适用于您,请注意getduration函数:http://www.zedwood.com/article/127/php-calculate-duration-of-mp3
https://stackoverflow.com/questions/41518271
复制相似问题