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?