0

I tried merging two audio files using following command,

 executeFfmpeg(`-i voice.wav -i background.wav -t ${duration+2} -filter_complex amix=inputs=2:duration=longest output.wav`)
        .on('error', function(err) {
          console.log('An error occurred: ' + err.message);
        })
        .on('end', function() {
          console.log('Merging finished !');
        }).run();

But I also want to fade out the audio in the end, So to do that I tried the following code,

  executeFfmpeg(`-i voice.wav -i background.wav -t ${duration+2} -vf "fade=t=out:st=${duration-1}:d=3" -filter_complex amix=inputs=2:duration=longest output.wav`)
        .on('error', function(err) {
          console.log('An error occurred: ' + err.message);
        })
        .on('end', function() {
          console.log('Merging finished !');
        }).run();

But the background audio volume is unchanged. Working with ffmpeg for the first time. So don't know what's happening. Need help :(

Bucky
  • 1,116
  • 2
  • 18
  • 34

1 Answers1

0

Combined command:

executeFfmpeg(`-i voice.wav -i background.wav -filter_complex "amix=inputs=2:duration=longest,afade=t=out:st=${duration-1}:d=1" output.wav`)
  • Just add to your -filter_complex instead of adding a separate -vf (-vf is for simple filtering of video).
  • Use afade, not the fade filter.
llogan
  • 121,796
  • 28
  • 232
  • 243