Search code examples
ffmpeg

Combining voices while considering their start time


Combine voices and add them to a video

I have this FFMPEG command to:

  1. Remove current video audio.
  2. Combine some voices and add them to the video.
ffmpeg -i vid.mp4 -i voice1.mp3 -i voice2.mp3 -filter_complex "[1:a] [2:a] amix=inputs=2:duration=longest:dropout_transition=0" -c:v copy -an vid.mkv

The above command works great.

Each voice has a start time

I have a new requirement. Each voice should start at its own specific start time. Like:

  1. Voice 1 starts at 2 sec of the video.
  2. Voice 2 starts at 1 sec of the video.

How can I modify my FFMPEG command so that each voice would be at its own proper start time?


Solution

  • I tested this approach, and it works:

    ffmpeg -i vid-in.mkv -i voice1.wav -i voice2.wav -filter_complex "[1:a]adelay=5000|5000[a1]; [2:a]adelay=10000|10000[a2]; [a1][a2]amix=inputs=2:duration=longest:dropout_transition=0"  -c:v copy -an vid.mkv
    

    I was suggested here: https://poe.com/s/9po0ZSqwk6PjskQyD5ou