I'm trying to merge an audio file with a video file.
I have two options:
-
Have a very small video file (e.g., 10 seconds) that loop while the audio file is not over.
-
Have a very long video file (longer than any of my audio file) on which I can attach the audio file. I would like to cut the video when the audio is finished.
I'm using the latter with the -t <duration in second>
option of ffmpeg. It means I have to get the duration of the audio file to feed it into ffmpeg. Is it possible to avoid this step?
Any pointer for the first solution?
Best Answer
If you want to merge new Audio with video repeat video until the audio finishes, you can try this:
Using -stream_loop -1 means infinite loop input.mp4, -shortest means finish encoding when the shortest input stream ends. Here the shortest input stream will be the input.mp3.
And if you want to merge new Audio with video repeat audio until the video finishes, you can try this:
use -y option will overwrite output files without asking.