user36521: I am attempting to create a video loop by merging a 15 second video with about 4 minutes of audio. After finding a similar question, I found a command that loops the input video for the length of the audio, and results in a merged video file that plays like I intended.
ffmpeg -stream_loop -1 -i loop.mp4 -i audio.mp3 -shortest -map 0:v:0 -map 1:a:0 -c copy output.mp4
While the resulting video plays as I wanted, I noticed that the file size is much larger than I expected. I presume I am not understanding what the -stream_loop option is actually doing. In my case, I input a 45Mb video clip and a 6Mb audio clip, yet the resulting video is about 690Mb. The video loop repeats about 15 times before the audio is done. Since 45Mb * 15 + 6Mb is about 680Mb, it looks like -stream_loop is not instancing the clip, and is just repeating the memory. I expected a file size not much larger than the sum of the input files' sizes, just over 50Mb.
I found several other questions and answers regarding merging a video loop with an audio track, but I didn't find anyone commenting about the resulting file size. Admittedly, I am a beginner with this process, but my expectation was the default behavior for a command that creates a loop from an input source would be to efficiently instance it whenever possible.

Is the -stream_loop option actually repeating the input video clip frames to make the loop?
Is there a way to tell ffmpeg to instance the input video frames when creating the loop?
Is this actually a limitation with video formats (e.g. mp4, mkv, etc.)?
If ffmpeg is not sufficient for this, is there some way to create a video that efficiently (with respect to file size) loops the video clip for the duration of an audio clip?


user1871: 
Is the -stream_loop option actually repeating the input video clip frames to make the loop?

Yes.

Is there a way to tell ffmpeg to instance the input video frames when creating the loop?

No.

Is this actually a limitation with video formats (e.g. mp4, mkv, etc.)?

For MP4s and MKVs, yes.

If ffmpeg is not sufficient for this, is there some way to create a video that efficiently (with respect to file size) loops the video clip for the duration of an audio clip?

Not that I know of. Some vendors like Whatsapp have customized MP4s to allow this. However, the player has to recognize and implement the proprietary loop instruction.

36521: <p>I am attempting to create a video loop by merging a 15 second video with about 4 minutes of audio. After finding a <a href="https://stackoverflow.com/questions/5015771/merge-video-and-audio-with-ffmpeg-loop-the-video-while-audio-is-not-over/55841289#55841289">similar question</a>, I found a command that loops the input video for the length of the audio, and results in a merged video file that plays like I intended.</p>
<p><code>ffmpeg -stream_loop -1 -i loop.mp4 -i audio.mp3 -shortest -map 0:v:0 -map 1:a:0 -c copy output.mp4</code></p>
<p>While the resulting video plays as I wanted, I noticed that the file size is much larger than I expected. I presume I am not understanding what the <em>-stream_loop</em> option is actually doing. In my case, I input a 45Mb video clip and a 6Mb audio clip, yet the resulting video is about 690Mb. The video loop repeats about 15 times before the audio is done. Since 45Mb * 15 + 6Mb is about 680Mb, it looks like <em>-stream_loop</em> is not instancing the clip, and is just repeating the memory. I expected a file size not much larger than the sum of the input files' sizes, just over 50Mb.</p>
<p>I found several other questions and answers regarding merging a video loop with an audio track, but I didn't find anyone commenting about the resulting file size. Admittedly, I am a beginner with this process, but my expectation was the default behavior for a command that creates a loop from an input source would be to efficiently instance it whenever possible.</p>
<ol>
<li>Is the <em>-stream_loop</em> option actually repeating the input video clip frames to make the loop?</li>
<li>Is there a way to tell ffmpeg to instance the input video frames when creating the loop?</li>
<li>Is this actually a limitation with video formats (e.g. mp4, mkv, etc.)?</li>
<li>If ffmpeg is not sufficient for this, is there some way to create a video that efficiently (with respect to file size) loops the video clip for the duration of an audio clip?</li>
</ol>
 1871: <blockquote>
<p>Is the -stream_loop option actually repeating the input video clip frames to make the loop?</p>
</blockquote>
<p>Yes.</p>
<blockquote>
<p>Is there a way to tell ffmpeg to instance the input video frames when creating the loop?</p>
</blockquote>
<p>No.</p>
<blockquote>
<p>Is this actually a limitation with video formats (e.g. mp4, mkv, etc.)?</p>
</blockquote>
<p>For MP4s and MKVs, yes.</p>
<blockquote>
<p>If ffmpeg is not sufficient for this, is there some way to create a video that efficiently (with respect to file size) loops the video clip for the duration of an audio clip?</p>
</blockquote>
<p>Not that I know of. Some vendors like Whatsapp have customized MP4s to allow this. However, the player has to recognize and implement the proprietary loop instruction.</p>
