0
A
回答
0
这是我用的http://www.sourcerally.net/Scripts/20-PHP-MP3-Class
<?php
// This is the class to generate mp3 files based on the anti-spam words
// Based on the PHP mp3 class at http://www.sourcerally.net/Scripts/20-PHP-MP3-Class
// Output code based on the FPDF class at http://www.fpdf.org
class Mp3Helper
{
function convert($fromFile, $toFile)
{
exec("ffmpeg -i $fromFile -ab 128k $toFile");
unlink($fromFile);
}
function concatenate($tempFile, $phrases)
{
exec("mp3wrap " . $tempFile . " " . $phrases);
}
function fix($tempFile, $toFile)
{
exec("ffmpeg -y -i " . $tempFile . " -acodec copy " .$toFile);
unlink($tempFile);
}
}
?>
<?php
// This is the class to generate mp3 files based on the anti-spam words
// Based on the PHP mp3 class at http://www.sourcerally.net/Scripts/20-PHP-MP3-Class
// Output code based on the FPDF class at http://www.fpdf.org
class Mp3
{
var $str;
var $time;
var $frames;
// Create a new mp3
function mp3($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 '';
}
}
?>
+0
我可以在视频中放置图像吗? – 2011-03-31 19:16:10
+0
这不是一个视频,它只是连接MP3,但与执行ffmepg作为一个exec的例子,你可以给如何把它放在一起的想法,:) – jjchiw 2011-03-31 20:13:47
相关问题
- 1. FFMPEG将mp4文件和mp3文件合并为mp4
- 2. 发送.mov文件通过管道的ffmpeg(标准输入)
- 3. 使用AVAssetReader和AVAssetWriter将* .mp3与* .mov文件合并
- 4. 阅读标签为几个MP3文件
- 5. ffmpeg输出文件不同
- 6. 为什么这两个ffmpeg文件不同(管道与文件输出)?
- 7. FFMPEG:如何使用FFMPEG将附加图片(APIC)从源mp3文件转码为目标mp3文件?
- 8. 在fluent-ffmpeg中输出多个文件
- 9. 加入两个MP3文件到一个
- 10. 输入一个文本文件,并在Python中写入多个输出文件
- 11. 如何使用ffmpeg将多个mp3文件重叠到一个mp3文件?
- 12. gzip几个文件,并将它们管入一个输入
- 13. 合并多个.mp3文件
- 14. 读取多个文件并写入多个输出文件
- 15. 连接mp3文件或使用java加入mp3文件
- 16. ffmpeg几个文件的处理
- 17. 将许多[两个mp3]文件加入许多[一个]文件
- 18. 如何合并/加入MP3文件与C#?
- 19. 将.mov文件转换为.h264文件
- 20. 输出到几个日志文件? (Unity3D)
- 21. 调整两个输入mp3文件的体积而使用的ffmpeg
- 22. .mov文件转换为.flv文件转换问题ffmpeg使用PHP
- 23. 用FFmpeg混合2个mp3文件为Android
- 24. 一个模板到几个输出文件与fmpp
- 25. ffmpeg将iPhone中的两个mov文件组合起来
- 26. ffmpeg的RTMP和本地文件输出
- 27. ffmpeg文件名输出格式
- 28. 合并几个pdf文件
- 29. 读取输入文本文件并写入特定输出文件的程序
- 30. 反应单个输入文件包的多个输出文件
http://lyncd.com/2009/02/how-to-merge-mp3-files/ – Brad 2011-03-31 16:53:56
这是帮助做到了不完全编程它,也许问http://audio.stackexchange.com/或http://superuser.com/ – Orbling 2011-03-31 16:57:01