With ffmpeg, I see how to add music file as background for a video, but the problem is how to make the audio loop/repeat. Is there a way out?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
ffmpeg
has the promising -loop_input
flag, but it doesn't support audio inputs yet.
I'd recommend sox
and the -shortest
option for ffmpeg
as a solution.
sox -i short_audio.mp3 looped_audio.mp3 repeat 1000 # adjust count as necessary
ffmpeg -i input_video.mp4 -i looped_audio.mp3 -shortest output_video.mp4
The sox command will loop the input, and the ffmpeg command will use it for the audio, but stop when it runs out of video to process.
回答2:
A bit late, but I just run into the same problem and managed to do it by using ffmpeg and concatenate filter. Here is an example of how to loop it three times:
ffmpeg -i audio.wav -filter_complex "[0:a]afifo[a0];[0:a]afifo[a1];[0:a]afifo[a2];[a0][a1][a2]concat=n=3:v=0:a=1[a]" -map "[a]" out.wav