FFMPEG: Loop video to the length of audio
For video, stream_loop option should be used.

ffmpeg -y -stream_loop -1 -i video -i audio.mp3 -fflags +shortest -max_interleave_delta 50000 -c copy output.mp4


You'll have to use a very recent version of ffmpeg (> Nov '17) as stream_loop had a bug, only recently fixed.

Since video encoding is expensive in terms of time and CPU, I've used streamcopy. For most videos, this is fine. Else, you'll have to re-encode.



Edit: another bug related to stream_loop, see workaround below

ffmpeg  -stream_loop -1 -i 1.mp4 -c copy -v 0 -f nut - | ffmpeg -thread_queue_size 10K -i - -i 1.mp3 -c copy -map 0:v -map 1:a -shortest -y out.mp4