Open xts-bit opened 1 year ago
trying to add background audio to a video in nodejs express, but instead of adding audio to the video it removes the audio from video how to fix?
import { path as ffmpegPath } from '@ffmpeg-installer/ffmpeg'; import ffmpeg from 'fluent-ffmpeg'; import { fileURLToPath } from 'url'; import { dirname } from 'path'; import path from 'path'; ffmpeg.setFfmpegPath(ffmpegPath); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const video = path.resolve(__dirname, 'video3.mp4'); const audio = path.resolve(__dirname, 'video5.mp4'); const destination = path.resolve(__dirname, 'output.mp4'); setTimeout(() => { ffmpeg() .input(video) .input(audio) .complexFilter([ { filter: 'amix', options: { inputs: 2, duration: 'longest' } } ]) .on('end', async function (output) { console.log(output, 'files have been merged and saved.') }) .saveToFile(destination) }, 3000);
trying to add background audio to a video in nodejs express, but instead of adding audio to the video it removes the audio from video how to fix?