I've created a tool to create a grid of movies, like in the Brady Bunch opening. It's a cool, funny effect.
Here's a sample movie showing the grid.
The problem is that ffmpeg is choosing the shortest movie to determine the maximum length of overlaid videos, but still using the full length of the first audio track to determine the overall output movie length.
So all my videos stop moving when the shortest one ends, but the audio plays on for full length of the first movie.
How can I either (1) set the length of the output movie to the longest input movie or (2) match the audio length to the shortest movie length as well?
Based on this ffmpeg example usage which exhibits the same audio problem:
ffmpeg
-i 1.avi -i 2.avi -i 3.avi -i 4.avi
-filter_complex "
nullsrc=size=640x480 [base];
[0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft];
[1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright];
[2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft];
[3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright];
[base][upperleft] overlay=shortest=1 [tmp1];
[tmp1][upperright] overlay=shortest=1:x=320 [tmp2];
[tmp2][lowerleft] overlay=shortest=1:y=240 [tmp3];
[tmp3][lowerright] overlay=shortest=1:x=320:y=240
"
-c:v libx264 output.mkv
[0:a] atrim=duration=6.6
will force the output to stop after 6.6 seconds. I'm now working on how to determine the best length.