While making screencasts I always end up with a file having poorly synced audio and video streams. This is not container specific as this happens with all the formats - ogg, mkv, avi, mp4 etc. I guess this has something to do with ffmpeg.
After searching on Internet, I found that this can be fixed using itsoffset switch in ffmpeg. I also tested it and it works. But the question is how do I find exact lag between audio and video streams in seconds:milliseconds?? I tried ffmpeg -i but it always shows delay to be zero.
Do you know what a clapper is? It's an old device used in movie making and looks like this:
This is used by the editor to sync the video and audio together. You need this because there is nothing about audio and video streams that really allow a computer to work out how out of sync they are.
Your best course of action is to work out why your recording is going out of sync. It sounds like your computer might be underpowered (conjecture as I don't know how powerful your computer is). If you can't solve the syncing problem, then use a clapper (or make one) and then trial and error your way into syncing it back up.
Of course this only helps with fixed sync issues, if you have progressive sync issues then you can use the time signature to resync the streams and this is something the computer can help you with. Is suspect that's what ffmpeg is trying to do.