在HTML中结合音频文件 [英] Combining audio files in HTML

查看:175
本文介绍了在HTML中结合音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 HTML页面,它有两个30秒的ABC.mp3音频文件和15秒的XYZ.mp3。我需要以这样一种方式组合这两个文件,使得我得到一个30秒(AND NOT 45秒)的新文件PQR.mp3,其中一个文件在另一个文件上重叠/合并
任何类型的插件,javascript等都会对您有所帮助,同时保留HTML和HTML5。

解决方案

简单的回答:不,Javascript和HTML5都没有权力这样做。您将需要服务器端工具来执行此操作。例如ffmpeg和LAME,如果是MP3的话。



如果你真的需要在HTML的基础上进行这种操作,唯一的方法就是将这些程序绑定到一个php脚本或者NodeJS服务器,然后启动一项工作来完成你想要做的事情。然而,你必须写bash脚本或cronejobs来做到这一点。



编辑

对于 nodeJS ,您将需要编写自己的节点服务器应用程序。然后应用程序应该使用 socketIO node-fluent-ffmpg ,它也与之蹩脚。该应用可能看起来像这样

server:

  var io = require('socket.io')。listen(80); 
var exec = require('child_process')。exec;
io.sockets.on('connection',function(socket){
socket.on('mergeFiles',function(data){
var firstFile = data.firstFile;
var secondFile = data.secondFile;

//通过执行shell脚本执行ffmpg操作
execString =./yourscript.sh+ firstFile ++ secondFile

函数puts(error,stdout,stderr){sys.puts(stdout)}
exec(execString,puts);
});
$ b

< script src =/ socket.io/socket.io.js\">< ;; script> 
< script>
var firstFile = ABC.mp3;
var secondFile = XYZ.mp3;

var socket = io.connect('http:// localhost');
socket.emit('mergeFiles',{firstFile:firstFile,secondFile:secondFile} );
< / script>


I have a HTML page which has two audio files ABC.mp3 of 30 sec and XYZ.mp3 of 15 sec. I need to combine these two files in such a manner that I get a new file PQR.mp3 of 30 sec (AND NOT 45 sec) which has one file overlapped/merged over the other. Any kind of plug-ins, javascript etc. will be helpful, keeping HTML and HTML5 under consideration.

解决方案

Simple answer: No. Neither Javascript nor HTML5 have the power to do this. You will need server side tools to do this. For example ffmpeg and LAME in case of MP3.

If you really need to do such manipulations on a HTML basis, the only way is to bind these programms to a php script or NodeJS server that then starts a job to do what you want to do. Nevertheless you would have to write bash script or cronejobs to do so.

edit

For nodeJS you will need to write your own node server application. The application then should be using socketIO and node-fluent-ffmpg which also has lame with it. The app could look like this

server:

var io = require('socket.io').listen(80);
var exec = require('child_process').exec;
io.sockets.on('connection', function (socket) {
  socket.on('mergeFiles', function (data) {
    var firstFile = data.firstFile;
    var secondFile = data.secondFile;

    //do ffmpg stuff by executing a shell script
    execString = "./yourscript.sh " + firstFile + " " + secondFile

    function puts(error, stdout, stderr) { sys.puts(stdout) }
    exec(execString , puts);
});

client:

<script src="/socket.io/socket.io.js"></script>
<script>
  var firstFile = ABC.mp3;
  var secondFile = XYZ.mp3;

  var socket = io.connect('http://localhost');
  socket.emit('mergeFiles', { firstFile: firstFile, secondFile: secondFile });
</script>

这篇关于在HTML中结合音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆