Add audio (with an offset) to video with FFMPEG

2019-07-03 22:43发布

I have a 10 minute video and a 50 minute audio mp3. The video starts at 500 seconds into the audio. Using FFMPEG, how can I add the the audio to the video but specify a 500 seconds audio offset (So that they sync up)?

EDIT:

Down the bottom of this page it suggests how to specify an offset.

$ ffmpeg -i video_source -itsoffet delay -i audio_source -map 0:x -map 1:y .......

However, when I apply this, it still starts the audio from the start.

2条回答
▲ chillily
2楼-- · 2019-07-03 23:01

I couldn't get audio to offset properly either, and some searching suggests that -itsoffset is currently broken.

You could try and get/compile an old version of ffmpeg before it broke (which doesn't sound like much fun).

Alternately, you could pad your audio with the necessary silence using something like sox and then combine:

sox -null silence.mp3 trim 0 500    # use -r to adjust sample-rate if necessary
sox silence.mp3 input.mp3 padded_input.mp3
ffmpeg -i in.avi -i padded_input.mp3 out.avi
查看更多
Bombasti
3楼-- · 2019-07-03 23:20

We are 8 years later, and the -itsoffset does work.

Exactly as in your linked page:

ffmpeg -i input_1 -itsoffset 00:00:03 -i input_2

Note that you place the -itsoffset switch before the input you want to delay, in this case input_2 will be delayed.

So in your case that the video starts later, you would add -itsoffset 00:08:20 before the video input.

查看更多
登录 后发表回答