Concatenates multiple audio files using ffmpeg
.
promise-audioconcat
provides a programmatic interface to do basically the same as calling ffmpeg
via CLI like:
ffmpeg -i "concat:audio1.mp3|audio2.mp3" -acodec copy out.mp3
npm install promise-audioconcat
import audioconcat from 'promise-audioconcat';
const audioconcat = require('promise-audioconcat');
- inputs: an array of the filenames of the audio files to concatenate
- output: the filename of the output file
Note: The output file will be overwritten if it exists.
const songs = [
'introduction.mp3',
'recording.mp3',
];
const output = 'combined.mp3';
try {
await audioconcat(songs, output);
console.log(`Audio created in ${output}`);
} catch (err) {
console.error('Error:', err);
console.error('ffmpeg stderr:', err.stderr);
}
- audioconcat - The package that inspired this one
- fluent-ffmpeg - The underlying ffmpeg library
- @ffmpeg-installer/ffmpeg - Provides the required ffmpeg binaries