whitebear
whitebear

Reputation: 12433

Loop movie and mix with audio by ffmpeg

I have a movie file and an audio file with different length.

Audio file is longer than video file.

I want to loop video and mix with audio, then set length same as audio file.

ffmpeg -i "Pentagon_VJ_background_loop.mp4" -stream_loop -1 -t 60 -i "Out1.wav"  -map 0:0 -map 1:0 output.mp4

With this I have -stream_loop -1 but movie doesn't loop. and have no way to set the length to audio file(I use -t 60 instead).

Does anyone help??

Upvotes: 0

Views: 375

Answers (1)

martinr92
martinr92

Reputation: 718

ffmpeg -stream_loop -1 -i "Pentagon_VJ_background_loop.mp4" -i "Out1.wav" -shortest -map 0:0 -map 1:0 output.mp4

Explanation:

  • -stream_loop -1 must be placed before the file that you want to loop
  • -shortest tells ffmpeg that output.mp4 should have the duration of the shortest input. Since the video is now an endless video, the shortest input is the audio file.

Upvotes: 3

Related Questions