3

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

2 Answers 2

9

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:

  1. (only for mac) install HomeBrew.
  2. 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

1
  • Thanks for the advice! ;) I already use RecorderRTC for the recording but I create "my own package" for ffmpeg command... -_- I don't searched for a package... But now everything goes right! ;)
    – RikyTres
    Jan 8, 2014 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.