1

Code has taken from following answer: FFmpeg - Overlay one video onto another video? and then little bit modified.

ffmpeg -i stream1.mp4 -i stream2.mp4 \
-filter_complex "[1:v]setpts=PTS+5/TB[a]; \
                 [0:v][a]overlay=enable=gte(t\,5):shortest=1[out]; \
                 [0][1]amix[a]" \
-map [out] -map [a] \
-c:v libx264 -crf 18 -pix_fmt yuv420p \
-y output.mp4

stream1.mp4 duration, eg: 35 seconds and stream2.mp4 duration, eg: 30 seconds. I want to start overlay (stream2.mp4) video+audio after 5 seconds. Overlay (stream2.mp4) video starts as expected.

But overlay (stream2.mp4) audio starts from beginning. How do I start overlay (stream2.mp4) audio after 5 seconds also?

Tarique Iqbal
  • 13
  • 1
  • 4

1 Answers1

0

Add the adelay filter:

ffmpeg -y -i stream1.mp4 -i stream2.mp4 \
-filter_complex "[1:v]setpts=PTS+5/TB[v]; \
                 [0:v][v]overlay=enable=gte(t\,5):shortest=1,format=yuv420p[out]; \
                 [1:a]adelay=5s:all=1[a1];[0][a1]amix[a]" \
-map [out] -map [a] \
-c:v libx264 -crf 18 \
output.mp4

If your ffmpeg is outdated you will have to use milliseconds and declare the delay for each channel, such as adelay=5000|5000.

llogan
  • 121,796
  • 28
  • 232
  • 243