3

I can edit my movie in some video editor and perfectly match audio with video, but in that case I would have to re-encode the entire video which would be time consuming. Code like:

ffmpeg -i my_movie.mp4 -c:v copy -c:a aac -af "audio_filter_help_me_guys" fixed_movie.mp4

would save my time. Or I just have to use video editor such as Kdenlive?

1
  • I'm not sure what you're asking, but vlc can adjust the audio forward/backward compared to video when you watch it, meaning no change is required.
    – guiverc
    Commented Oct 2, 2019 at 3:34

1 Answer 1

5

You should not reencode neither the video nor the audio, but just delay the audio stream. The -itsoffset option of ffmpeg serves the purpose of adding an offset to the time stamp of a stream, such that it is delayed. The command therefore would be more like:

ffmpeg -i my_movie.mp4 -itsoffset 0.5 -i my_movie.mp4 -map 0:v -map 1:a -c:copy fixed_movie.mp4
  • -itsoffset 0.5 -i my_movie.mp4 specifies that the second input file (which, in this case, happens to be the same as the first), should be delayed by 0.5 s.
  • -map 0:v -map 1:a selects only the video from the first input file, and only the audio from the second (delayed) stream. These woulld not be needed if you had two files, one with only the video stream and the other with only the audio stream.
  • -c:copy indicates all streams should be copied (and is a shortcut notation equivalent to -c:v copy -c:a copy)

You should also be able to achieve this with the graphical tool Avidemux, but my experience is that it does not always work reliably. The command line is, once you found the options, way faster.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .