简体   繁体   中英

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??

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM