首页 > 解决方案 > 我正在尝试使用 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);

标签: phpcodeigniter

解决方案


推荐阅读