I want to trim and concat several audio files in Node.js. I found FFmpeg
and it looks like it does what I need, but I don't know how to use it in Node since the installation is through apt-get
. Theoretically, I can use what's called child_process
to execute several mands from bash, but I'm not sure if this is performant.
I want to trim and concat several audio files in Node.js. I found FFmpeg
and it looks like it does what I need, but I don't know how to use it in Node since the installation is through apt-get
. Theoretically, I can use what's called child_process
to execute several mands from bash, but I'm not sure if this is performant.
- Possible duplicate of Audio manipulation using node.js – AP. Commented Feb 20, 2018 at 20:04
- 2 Not exactly. That thread is 4 years old and has 2 answers while in JS you get new framework every week :P – feerlay Commented Feb 20, 2018 at 20:07
1 Answer
Reset to default 8Of course you can do this by spawning a child_process and use ffmpeg this way. This should perfectly works without any noticeable performance problem.
However there is a fluent-ffmpeg package that you could use for more convenience.
For example you can trim a file with the -t duration
option and concat files with -f concat
option. You can also use the builtin method mergeToFile()
.
Example:
// trim file
ffmpeg('input.wav')
.inputOptions('-t 2') // 2s
.output('output.wav')
.run()
// merge file
ffmpeg('input.wav')
.input('input2.wav')
.mergeToFile('merged.wav')