Sometimes you come across a poorly created video file where the audio and the video are slightly out of sync with each other. Rather than using a big powerful video editing package, you can use
ffmpeg to adjust the times without re-encoding. The key is the
itsoffset option. The
ffmpeg command line is almost a programming language unto itself, but it is not too hard once you get used to it.
A simple example:
ffmpeg -i input.mp4 -itsoffset -0.25 -i nput.mp4 -map 0:0 -map 1:1 -c copy retimed.mp4
This assumes a simple video file with one video and one audio stream. If you have a more complex file you will have to adapt the mappings accordingly. That is out of scope for this example.
What we are doing here is using the same input file as two separate inputs, one for the video and one for the audio, and applying the offset to the video. I had a video where the audio was a quarter of a second ahead of the audio. So here, I move the video relative to the audio backwards by 0.25 seconds. It then copies the video of stream one (map 0:0), and the audio from stream two (map 1:1), and copies the streams together into a new file called