php - 我正在尝试使用 getID3 库在 php 中修剪音频文件。我得到了一个随机字符串。如何将其转换为正确的文件。可以播放
问题描述
我正在尝试使用 getID3 库在 php 中修剪音频文件。我得到了一个随机字符串。如何将其转换为正确的文件。可以播放
$getID3 = new getID3();
$id3_info = $getID3->analyze('assets/upload/'.$new_audio_name);
list($t_min, $t_sec) = explode(':', $id3_info['playtime_string']);
$time = ($t_min * 60) + $t_sec;
$preview = $time / 30; // Preview time of 30 seconds
$handle = fopen('assets/upload/'.$new_audio_name, 'r');
$content = fread($handle,filesize('assets/upload/'.$new_audio_name));
$length = strlen($content);
$length = round(strlen($content) / $preview);
$content = substr($content, $length / 3, $length);
header("Content-Type: {$id3_info['mime_type']}");
header("Content-Length: {$length}");
print_r($content);
解决方案
推荐阅读
- c# - 在 Unity 中动态创建 GameObject 标签
- tfs - TFS 2015 - 进程配置文件显示重复状态
- mysql - 如何连接到我的 Amazon Lightsail 实例上的本地 MySQL?
- c# - 无法访问此页面 VS 2015
- javascript - 如何从分页端点导出项目总数?
- python - 无法从datalab查询表
- java - 使用 Jackson 时如何避免反序列化 JSON 字符串中的空 JSON 数组元素
- cpanel - 坏壳在 vps 上自动创建坏帐户
- vue.js - v-data-table 对单元格的自定义
- java - 忽略基于另一个字段值的序列化字段