FFMPEG resyncing audio
I have a video file with 2 audio streams
the 2nd audio stream is out of sync
How can I use FFMPEG to fix this?
All suggestions welcome,
Thanks in advance!
15 Replies
It depends - is the audio ahead of the video, or is the video ahead of the audio? And by how much?
If the audio is coming in before the video, then you would need a command like this:
ffmpeg -i "YOUR_INPUT_FILE" -itsoffset SS.MS -i "YOUR_INPUT_FILE" -map 1:v -map 0:a -c copy "OUTPUT_FILE"
Otherwise if the audio is coming after where it should in the video, then you would need a command like this to delay the video stream
ffmpeg -i "YOUR_INPUT_FILE" -itsoffset SS.MS -i "YOUR_INPUT_FILE" -map 0:v -map 1:a -c copy "OUTPUT_FILE"
replace SS.MS
with the seconds and milliseconds of delay you want to apply2nd audio stream has a delay of
716.67ms
or
43 frames
so it needs to start earlier
OR
have the Video Stream + Audio Stream 1 delayed by that same amount of time
will play around with what you have given me already!
Thanks 🙂
Then you'll want to run this command
ffmpeg -i "YOUR_INPUT_FILE" -itsoffset 0.7167 -i "YOUR_INPUT_FILE" -map 0:v -map 1:a -c copy "OUTPUT_FILE"
OK I tried it but that just delayed the audio for audio stream 1
Oh my mistake, it should be this instead:
ffmpeg -i "YOUR_INPUT_FILE" -itsoffset 0.7167 -i "YOUR_INPUT_FILE" -map 0:v -map 1:a:1 -c copy "OUTPUT_FILE"
The change here is from -map 1:a
to -map 1:a:1
to specify the 2nd audio source instead of the first one (which would be -map 1:a:0
)Hmmmmm now there is no audio from audio stream 1 and Audio stream 2 is now even more delayed
I'm starting to wonder if it is even possible at all?
I appreciate your suggestions btw!
I think we just miscommunicated
ffmpeg -i "YOUR_INPUT_FILE" -itsoffset 0.7167 -i "YOUR_INPUT_FILE" -map 1:v -map 0:a:1 -c copy "OUTPUT_FILE"
OK so now Audio Stream 2 is in sync with the Video but there is now Audio from Audio stream 1
for a litle more context
hmmm
ffmpeg -i "YOUR_INPUT_FILE" -itsoffset 0.7167 -i "YOUR_INPUT_FILE" -map 1:v -map 1:a:0 -map 0:a:1 -c copy "OUTPUT_FILE"
thereYou sir, are an absolute genius.
GG @brainz26, you just advanced to level 7 !
It works perfectly now
thank you so much!
you have potentially saved me hours and hours of time now haha
honestly really appreciate it this has been something I've attemtped on and off now for months lol
Glad I could help!