2

I have a 10 seconds video clip and 60 seconds audio clip, so when I mux it with

mkvmerge --output video.mkv ./a.mp3 ./a.mp4

The output file shows the video only for the first 10 seconds, and then the last frame is displayed for 50 seconds.

How can I loop the video in automatic mode so that it repeats for the whole 60 seconds with mkvmerge or any other command line tool (I need to automate it as I have to do it for 400 files)?

1 Answer 1

4

To merge an audio stream with a repeated video stream

ffmpeg -stream_loop -1 -i 20s.ts -i 120s.mp3 -map 0:v:0 -map 1:a:0 -shortest -c copy output.mp4
  • -stream_loop -1 : to loop infinity of video input stream
  • -map 0:v:0 : pick the video of the first input stream
  • -map 1:a:0 : pick the audio of the second input stream
  • -shortest : select the shortest length of input streams, which is the audio stream since the video will be looped infinity
  • -c copy : no video and audio transcodes.
1
  • It worked, thanks!
    – IvanD
    Commented Mar 27, 2022 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.