Concatenating audio with image for video in ffmpeg causes infinite video

I’m attempting to concatenate 2 audio files, with a 5 second silence between them. This will also have a still image for the video.

I’m following the example of the same thing here How can I add specific lengths of silence between tracks with ffmpeg?

ffmpeg \
  -loop 1 -i image.jpg
  -i audio1.wav \
  -f lavfi -t 5 -i anullsrc \
  -i audio2.wav \
  -filter_complex "[1:a][2:a][3:a]concat=n=3:v=0:a=1[outa]" \
  -map 0:v -c:v copy \
  -map "[outa]" -c:a aac -b:a 192k \
  -shortest \
  out.mkv

This correctly joins the audio with a 5 second silence, however this creates a mkv file that is infinitely long with silence after the joined audio ends. I’ve gone through the docs but I don’t see anything obviously wrong. I thought the -shortest option would prevent this but it doesn’t.

How would I fix this to stop at the end of the concatenated audio?

Read more here: Source link