0

The amix merging the both audio work fine. But when I try to add the aloop filter, I got an error :

Error: ffmpeg exited with code 1: Cannot find a matching stream for unlabeled input pad 1 on filter Parsed_amix_1

My code:

ffmpeg()
    .input(audio.path)
    .input('assets/plateform-tags/default_tag_male.mp3')
    .complexFilter
     ([
        { filter: 'aloop', options: { loop: -1, size: 100, start: 1 }},
        { filter: 'amix', options: { inputs: 2, duration: 'longest' }},
     ])
    .on('error', (err) => {
        console.log(err)
     })
     .on('end', async function (output) {
         console.log(output, 'Files have been merged and saved')
      }).saveToFile('assets/plateform-tags/tagged_version.mp3')

Any suggestions ? Thank's ! Up !

mehdibe
  • 177
  • 2
  • 12

1 Answers1

0

Here is how I did this:

const complexFilters = [
        {
            filter: "volume",
            inputs: "0:0",
            options: ["1.0"],
            outputs: "[s1]"
        },
        {
            filter: "volume",
            inputs: "1:0",
            options: ["0.2"],
            outputs: "[s2]"
        },
        {
            filter: "aloop",
            inputs: "[s2]",
            options: ["loop=-1"],
            outputs: "[s3]"
        },
        {
            filter: "amix",
            inputs: ["[s1]", "[s3]"],
            options: ["duration=first", "dropout_transition=0"]
        }
    ];

ffmpeg()
    .input(mergedAudioFilePath)
    .input(backgroundMusicFilePath)
    .complexFilter(complexFilters)
    .save(resultFilePath)
Eliz
  • 160
  • 1
  • 5