How do I remove excess video duration in ffmpeg when using lavfi? My goal is to take clips that last over 40 seconds and overlay them on a background, then trim the total time once the clips and background fade out.  It works great, except the seeking goes up to 24 seconds even when I specify 21.

ffmpeg -y -framerate 60 -loop 1 -ss 0 -t 21 -i ~/Desktop/FP2.tiff -ss 0 -t 21 -i ~/Desktop/fp.mov -lavfi \
"[0]fade=t=in:st=0:d=1,fade=t=out:st=20:d=1,trim=end=21[bg]; \
[1:v]setpts=(PTS-STARTPTS)+1/TB,fifo,fade=t=in:st=1:d=2,fade=t=out:st=15:d=2[fade]; \
[bg][fade]overlay=10:(main_h-overlay_h)/2:format=rgb[v1]; \
[1:v]setpts=(PTS-STARTPTS)+3/TB,fifo,fade=in:0:120,fade=t=out:st=18:d=2[v2]; \
[v1][v2]overlay=460:(main_h-overlay_h)/2:format=rgb[video]; \
[1:a]adelay=1000|1000,stereotools=muter=1,afade=t=in:st=1:d=2,afade=t=out:st=15:d=2[a1]; \
[1:a]adelay=3000|3000,stereotools=mutel=1,afade=t=in:st=3:d=2,afade=t=out:st=18:d=2[a2]; \
[a1][a2]amix=inputs=2[audio]" \
-map [video] -map [audio] -c:v ffv1 -level 3 -c:a pcm_s16be ~/Desktop/filtergraph.nut


You can see this in ffplay; the background will fade completely by the 21 second mark, but the video itself ends at 24 seconds.  How do I get them to match exactly?  I'm aware I can use -ss and -t after the inputs, but that method can be slow if you intend to use a start point past 0.
You are feeding 21 seconds of audio from the video file and then applying adelay=3000|3000, hence 24 seconds. Add atrim=end=21 at the end to both your audio filterchains.

And

Add shortest=1 to both your overlays.