Node.js — как наложить mp3 на другой трек?

Добрый день!

Хочу добавить watermark к загружаемым трекам (mp3, wav) на сервер node.js. Т.е. на звук mp3 наложить другой звук mp3 поверх, каждый секунд 10, например.

Как их смешать?

Пробовал с помощью 'ffmpeg':

const command = ffmpeg();
  const outputFileName = `overlayed-${Date.now()}.mp3`; // Generate a unique file name
  return await command
    .addInput('/1.mp3')
    .addInput('/watermark.wav')
    .complexFilter([
      {
        filter: "amix",
        inputs: ["0:0", "1:0"],
      },
    ])
    .output('/2.mp3') // Use the generated file name
    .outputOptions("-y") // add this line to overwrite the output file
    .setStartTime("00:00:00")
    .setDuration("15")
    .on("error", function (err) {
      console.log(err);
    })
    .on("end", function () {
      return "ok";
    })
    .run();


но выдаёт ошибку:

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with
 the reason "#<Object>".] {
  code: 'ERR_UNHANDLED_REJECTION'
}
  • Вопрос задан
  • 139 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы