Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add audio (with an offset) to video with FFMPEG

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.

like image 877
slotishtype Avatar asked Sep 15 '11 05:09

slotishtype


People also ask

How do I add audio delay in ffmpeg?

-itsoffset – this is an important parameter in this command because it instructs FFmpeg to add a delay of three seconds to the input streams. 3 literally means start the second input after three seconds of when the first input started. -c:a copy – tells FFmpeg for audio codec just copy it.

What is offset in ffmpeg?

The itsoffset option applies to all streams embedded within the input file. Therefore, adjusting timestamps only for a single stream requires to specify twice the same input file. adjusts timestamps of the input audio stream(s) only.

What ffmpeg command line syntax will pull the audio from a video file and save it as an mp3?

The -i option in the above command is simple: it is the path to the input file. The second option -f mp3 tells ffmpeg that the ouput is in mp3 format. The third option i.e -ab 192000 tells ffmpeg that we want the output to be encoded at 192Kbps and -vn tells ffmpeg that we dont want video.


1 Answers

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.

like image 154
ib11 Avatar answered Oct 12 '22 14:10

ib11