There are lots of different reasons why your audio might be out of sync with your video. Below are a few reasons why it may have happened and how to avoid it.
Shooting in a variable frame rate
A lot of phones and tablets shoot in variable frame rates by default, although this can be changed in the settings or using 3rd party video camera apps. Variable frame rates are good for optimising video based on the device’s speed and storage capabilities. Unfortunately, using variable frame rates will always cause issues for sound because they don’t conform to a standard frame rate when being imported into a video editing tool.
You can convert VFR footage to a constant frame rate. It is better to you get it right in camera but it is possible to salvage old footage using something like Handbrake to reexport it.
Recording on slow memory cards or drives
Slow memory cards can cause this issue, if the memory card can’t write fast enough it will inconsistently drop frames throughout the recording. Some cameras will just give a message and stop but most try to continue as best as possible. Some cards are fake, so you will think they are fast but they aren’t. Always be sure to check reviews before buying memory cards. I like to use the Sandisk Extreme series cards for all of my work. They can be expensive but when shooting video reliability is priceless.
Mixing audio formats causes audio sync issues
If you are planning to record sound separately on something like a Zoom microphone then be sure to record both sets of audio in the same format. In very simplified terms, 48Khz tends to be the standard for video recordings with attached audio and 44.1Khz is the standard for audio-only. A lot of audio devices will record in 44.1Khz by default but this can pose issues when trying to sync it up in post-production. So always make sure to set the audio to be recording in 48Khz and it will save a lot of headaches later down the line.
Fixing audio sync issues in general
The easiest way to fix audio drift is to take the original camera audio file and the external audio and use something like Premiere Pro to stretch the external audio to match the camera audio. If you do not have a separate audio track, unfortunately, you will need to cut and match the sections that are out of sync. There are tools in editing suites like Premiere Pro and Final Cut X that can help with this.