Sunday, December 30, 2018

Adjusting video/audio sync with ffmpeg

If you need to delay video by 3.84 seconds, use a command like this:
ffmpeg.exe -i "movie.mp4" -itsoffset 3.84 -i "movie.mp4" -map 1:v -map 0:a -c copy "movie-video-delayed.mp4"
If you need to delay audio by 3.84 seconds, use a command like this:
ffmpeg.exe -i "movie.mp4" -itsoffset 3.84 -i "movie.mp4" -map 0:v -map 1:a -c copy "movie-audio-delayed.mp4"
Make sure, that your ffmpeg build is not too old, newer than 2012 will suffice.

Explanation
-itsoffset 3.84 -i "movie.mp4"
Offsets timestamps of all streams by 3.84 seconds in the input file that follows the option (movie.mp4).
-map 1:v -map 0:a
Takes video stream from the second (delayed) input and audio stream from the first input - both inputs may of course be the same file.
A more verbose explanation can be found here:
http://alien.slackbook.org/blog/fixing-audio-sync-with-ffmpeg/

Reference

https://superuser.com/questions/982342/in-ffmpeg-how-to-delay-only-the-audio-of-a-mp4-video-without-converting-the-au

No comments:

Post a Comment