Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding repeated background audio with ffmpeg [closed]

Tags:

ffmpeg

audio

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?

like image 431
象嘉道 Avatar asked May 08 '11 20:05

象嘉道


People also ask

What is FFmpeg transcoding?

FFmpeg is a software, which uses all formats for media you may need – H. 264, H. 265, Apple ProRes, Avid DNxHD etc, even also used for images like PNG and others – support all type of platform you're on. It is a command-line tool, it is quicker than some other tools which are available for transcoding.


1 Answers

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

like image 52
blahdiblah Avatar answered Sep 21 '22 17:09

blahdiblah