我正在通过此功能合并多个音频文件(.wav),但现在我想指定输出文件的比特率。我应该怎么办?
function joinwavs($wavs) {
$fields = join('/', array('H8ChunkID', 'VChunkSize', 'H8Format',
'H8Subchunk1ID', 'VSubchunk1Size',
'vAudioFormat', 'vNumChannels', 'VSampleRate',
'VByteRate', 'vBlockAlign', 'vBitsPerSample'));
$data = '';
foreach ($wavs as $wav) {
$wav = str_replace('http://example.com/', '', $wav);
$fp = fopen($wav, 'rb');
$header = fread($fp, 36);
$info = unpack($fields, $header);
// read optional extra stuff
if ($info['Subchunk1Size'] > 16) {
$header .= fread($fp, ($info['Subchunk1Size'] - 16));
}
// read SubChunk2ID
$header .= fread($fp, 4);
// read Subchunk2Size
$size = unpack('vsize', fread($fp, 4));
$size = $size['size'];
// read data
$data .= fread($fp, $size);
}
return ($header . pack('V', strlen($data)) . $data);
}