以下代码是基于PHP 7.x 的,版本小于7.x 的请自行将 代码中的__construct 改为 mp3

<?php
class mp3 {var $str;var $time;var $frames;// Create a new mp3 function __construct($path="") {if($path!="") {$this->str = file_get_contents($path);}}// Put an mp3 behind the first mp3 function mergeBehind($mp3) {$this->str .= $mp3->str;}// Calculate where's the end of the sound file function getIdvEnd() {$strlen = strlen($this->str);$str = substr($this->str,($strlen-128));$str1 = substr($str,0,3);if(strtolower($str1) == strtolower('TAG')) {return $str;} else {return false;}}// Calculate where's the beginning of the sound file function getStart() {$strlen = strlen($this->str);for ($i=0;$i<$strlen;$i++) {$v = substr($this->str,$i,1);$value = ord($v);if($value == 255) {return $i;}}}// Remove the ID3 tags function striptags() {//Remove start stuff... $newStr = '';$s = $start = $this->getStart();if($s===false) {return false;} else {$this->str = substr($this->str,$start);}//Remove end tag stuff $end = $this->getIdvEnd();if($end!==false) {$this->str = substr($this->str,0,(strlen($this->str)-129));}}// Display an error function error($msg) {//Fatal error die('<strong>audio file error: </strong>'.$msg);}// Send the new mp3 to the browser function output($path) {//Output mp3 //Send to standard output if(ob_get_contents()) $this->error('Some data has already been output, can\'t send mp3 file');if(php_sapi_name()!='cli') {//We send to a browser header('Content-Type: audio/mpeg3');if(headers_sent()) $this->error('Some data has already been output to browser, can\'t send mp3 file');header('Content-Length: '.strlen($this->str));header('Content-Disposition: attachment; filename="'.$path.'"');}echo $this->str;return '';}//Save MP3function  saveMp3($filename) {$myfile = fopen($filename, "w") or die("Unable to open file!");fwrite($myfile,  $this->str);fclose($myfile);}
}
// First File: (Google speech)
$mp3 = new mp3('1.mp3');
$mp3->striptags();
//Second file
$second = new mp3("2.mp3");
$mp3->mergeBehind($second);
$mp3->striptags();//$mp3->output('word.mp3'); 下载文件
$mp3-saveMp3('word.mp3'); //保存文件
?>

PHP 将两个MP3 文件进行合并,可以多个MP3文件合并相关推荐

  1. php 根据一个数据组的id 取得另一个数据组对应的名称,怎样从两个spss的数据文件中选出id相同的数据,合并成一个文件...

    求教高手怎样从两个spss的数据文件中选出id相同的数据,合并成一个文件.谢谢.排序后用merge file操作,怎么原数据没有变化?output中提示这些 Renaming has created ...

  2. 怎么让两个java文件关联,怎么把多个excel文件合并成一个【几个excle合并成一个】...

    怎么把多个excel文件合并成一个 新建一个BOOK文件,按Alt F11这二个键,VBA编辑界面,点击编辑的菜单:"插入"--"",然后在里面完整复制下面的代 ...

  3. c语言两程序合并,C语言将两个文件的内容合并到第三个文件中

    原标题:C语言将两个文件的内容合并到第三个文件中 让给定的两个文件是file1.txt和file2.txt.以下是合并的步骤. 1)在读取模式下打开file1.txt和file2.txt. 2)在写入 ...

  4. linux下将多个文件去除文件头合并_Linux下把多个文件合并成一个文件 - 卡饭网...

    互盾PDF分割合并工具将多个PDF文件合并成一个PDF文档 互盾PDF分割合并工具将多个PDF文件合并成一个PDF文档     互盾PDF分割合并工具将多个PDF文件合并成一个PDF文档 一.下载并安 ...

  5. grunt合并压缩js、css文件

    参考文章如下: http://www.cnblogs.com/yexiaochai/p/3594561.html http://www.cnblogs.com/yexiaochai/p/3602002 ...

  6. mysql多行合并成一行_数据文件合并与拆分

    [摘要] 本文介绍将多个文本文件和 Excel 文件合并成一个文件,或者将一个文件拆分成几个小文件时,如何处理会遇到的几种情况,并用 esProc SPL 举例实现. 在数据处理业务中,经常要把文件结 ...

  7. php修改音频文件_解析用PHP读写音频文件信息的详解(支持WMA和MP3)

    // AudioExif.class.php // 用PHP进行音频文件头部信息的读取与写入 // 目前只支持 WMA 和 MP3 两种格式, 只支持常用的几个头部信息 // // 写入信息支持: T ...

  8. 将 a.txt 文件中的单词与 b.txt 文件中的单词交替合并到 c.txt 文件 中

    package again;import java.io.*;/* 1.编写一个程序,将 a.txt 文件中的单词与 b.txt 文件中的单词交替合并到 c.txt 文件 中,a.txt 文件中的单词 ...

  9. 如何使用手机将PDF合并呢?分享一个手机合并文件方法

    怎么使用手机把两个PDF文件合并到一起呢?大家在处理PDF文件的时候,很多情况下都需要编辑PDF文件,如文件中有错误的地方需要编辑,收到两个同类型文件需要合并等,而我们也不能保证每时每刻身边都有电脑, ...

  10. SwiftUI AVKit 之合并和叠加音频mp3 并输出

    实战需求 SwiftUI AVKit 之合并和叠加音频mp3 并输出 本文价值与收获 看完本文后,您将能够作出下面的界面 截屏2020-08-28 上午12.58.10.png 看完本文您将掌握的技能 ...

最新文章

  1. vs2013 乱码问题
  2. shell学习之常用命令总结
  3. RxJava 在Android中的应用(二)
  4. 成功解决mod = importlib.util.module_from_spec(spec)ImportError: DLL load failed: 找不到指定的程序。
  5. Flink异步io应用场景之流表join维表
  6. 如何监听RecyclerView划到最后一条数据
  7. vue 写bean_vue+jsp+删除一个bean
  8. day4_监控日志的脚本
  9. 宽带路由器-mac地址克隆
  10. 华夏基金:养老是基金业下一个20年最大风口
  11. 【笔记】《凤凰项目》读书笔记
  12. 抠图算法(交互式)以及证件照的自动抠图
  13. Windows系统日志分析工具-- Log Parser
  14. the little Redis book
  15. 精致生活品味相伴,Barsetto百胜图BAC025B胶囊咖啡机测评
  16. android APP 跳转到应用商店评分
  17. 学法减分助手PRO小程序源码
  18. RK3399平台开发系列讲解(网络篇)7.11、图解Linux网络包接收过程
  19. Java垃圾回收策略
  20. my ReadAnimal_hamster

热门文章

  1. MATLAB的MCC命令
  2. SpringBoot Mybatis Starter 解析
  3. 解决KEIL MDK编译生成Bin文件时,却生成了*bin文件夹
  4. CSS W3C 统一验证工具
  5. GSMA选举新的董事会成员,宣布Orange董事长兼首席执行官Stéphane Richard出任主席
  6. 研发管理05:项目管理经验总结
  7. eclipse如何设置中文
  8. 依分布收敛的定义细节
  9. linux系统取消自检,Linux 磁盘自检设置
  10. 中通hadoop去CDH的实践之路