问题
There's a way to merge an audio (wav) and a video (webm) in a nodejs server?
Since WebM is a container format, I hope that is possible add audio track to an existing WebM file. I'm right?
Anyone know a NodeJS package for doing this?
回答1:
Found a solution, but is not really simple to do. For do this is required ffmpeg (or similar).
To install it I done this steps:
- (only for mac) install HomeBrew.
run the installation of ffmpeg with all the dependences that is required:
sudo brew install ffmpeg --with-libvpx --with-theora --whit-libogg --with-libvorbis
now we can merge a audio and a video file with this shell command:
ffmpeg -i video-file.webm -i audio-file.wav -map 0:0 -map 1:0 output-file-name.webm
Here we can merge file from our shell, but what I needed was not this. I needed the capability to do this from a NodeJS server, and for doing this now we can run this code.
var util = require('util'),
child_process = require('child_process');
var exec = child_process.exec;
function puts(error, stdout, stderr) {
stdout ? util.print('stdout: ' + stdout) : null;
stderr ? util.print('stderr: ' + stderr) : null;
error ? console.log('exec error: ' + error) : null;
}
exec("ffmpeg -i video-file.webm -i audio-file.wav -map 0:0 -map 1:0 output-file-name.webm", puts);
This simple solution work fine for me.
回答2:
Take a look at this:
====> https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RecordRTC/RecordRTC-to-Nodejs
====> https://github.com/schaermu/node-fluent-ffmpeg
来源:https://stackoverflow.com/questions/20263131/merge-wav-audio-and-webm-video