user18764: E.g. if video is 1 minute, but audio is 1 hour. Make video loop throughout for 1 hour of the audio track.
I use this solution to loop image through the lenght of the audio
ffmpeg -y -loop 1 -r 6 -i image.jpg -i audio.mp3 -shortest -c:v libx264 -preset ultrafast -tune stillimage -pix_fmt yuv420p -c:a copy output.mp4

But it doesn't work for video, replacing image.jpg with video.mp4 will give error no loop found.

user35876: Well, now the default behavior of current/latest ffmpeg via:
c:\sbin\ffmpeg.exe -i "D:\video.m4s" -i "\audio.m4s" -c:v copy -c:a copy "D:\combined.mp4"

is padding/looping the last frame of the video until audio.length === video.length.
See if this is acceptable for you.
For details behavior:

if (audio.length < video.length), then pad the audio with silent, so that audio.length === video.length
if (audio.length > video.length), then pad the video with the last frame of this video, so that audio.length === video.length


user1871: 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


18764: <p>E.g. if video is 1 minute, but audio is 1 hour. Make video loop throughout for 1 hour of the audio track.</p>

<p>I use this solution to loop image through the lenght of the audio</p>

<pre><code>ffmpeg -y -loop 1 -r 6 -i image.jpg -i audio.mp3 -shortest -c:v libx264 -preset ultrafast -tune stillimage -pix_fmt yuv420p -c:a copy output.mp4
</code></pre>

<p>But it doesn't work for video, replacing image.jpg with video.mp4 will give error <code>no loop found</code>.</p>
 35876: <p>Well, now the default behavior of current/latest ffmpeg via:</p>
<pre><code>c:\sbin\ffmpeg.exe -i &quot;D:\video.m4s&quot; -i &quot;\audio.m4s&quot; -c:v copy -c:a copy &quot;D:\combined.mp4&quot;
</code></pre>
<p>is padding/looping the last frame of the video until <code>audio.length</code> === <code>video.length</code>.</p>
<p>See if this is acceptable for you.</p>
<p>For details behavior:</p>
<ul>
<li>if (<code>audio.length</code> &lt; <code>video.length</code>), then pad the audio with silent, so that <code>audio.length === video.length</code></li>
<li>if (<code>audio.length</code> &gt; v<code>ideo.length</code>), then pad the video with the last frame of this video, so that <code>audio.length === video.length</code></li>
</ul>
 1871: <p>For video, stream_loop option should be used.</p>

<pre><code>ffmpeg -y -stream_loop -1 -i video -i audio.mp3 -fflags +shortest -max_interleave_delta 50000 -c copy output.mp4
</code></pre>

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

<p>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.</p>

<hr>

<p><strong>Edit</strong>: another bug related to stream_loop, see workaround below</p>

<pre><code>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
</code></pre>
