I use MEGUI using X264 and FAAC. This is unfortunately Windows Only because it uses AviSynth. You may get MPlayer's MEncoder (mplayerhq.hu) to do it for you on other platforms.
A common problem I find is when files are at an odd framerate, such as 23.9766484732 (ca) - if they are then muxed to 25 fps, you get into problems
A quick mini-quide..
Download MEGUI (doom9.org is where I found it)
Run MEGUI once to have it update itself and all plugins.
Use the AviSynth script creator (in menu) to create .avs files for each of your sources.*
Load these, one by one, into MEGUI's main window.
Setup MEGUI to use X264 as video encoder and set up a profile (AVC High Profile, level 4.1, any option).
Enqueue video as MP4 and start
Load source file as audio source
Setup audio to use FAAC-MP4 and configure a profile
Enqueue audio as MP4
Use MP4Box muxer (in MEGUI menu) to mux the resulting files. Since they are kept as MP4, you should have no drift or sync problems.
If you STILL have sync problems, it can be the source files or any codec installed on your system.
I then use AtomicParsley to set up information on the MP4s based on IMDB or EPGuides.com. More on that if needed. Unfortunately, Twonky does not understand half of the MP4+Quicktime tags
Cheers,
Nc.
*: longer files at just-under-24fps framerates (~23.975) may fail at playback due to stupid players not understanding 64bits timestamps. In AviSynth, use "assumefps(24000,1001)" to try and correct.