I was using AVIdemux to trim a MPEG4 and convert it to a MKV so I could add some soft subtitles, but the video of the resulting file plays strangely slowly, lagging behind the audio. I checked it with MediaInfo, but the framerate is what it should be.
That therein is the problem. With avidemux I found out that when converting between codecs you need to adjust the framerate. The setting is up on top video/framerate. You need to play with it till you get the audio sync up. I usually use 23.976/25.000/29.976, but you can try different settings. The good thing about avidemux is you can preview if the video/audio will be insync in realtime by just clicking on the output window and pressing the play arrow. If the video/audio is insync you can save it.
That sounds like you have tried editing something with a barely supported codec. Avidemux uses ffmpeg which while it can handle most things does have a few problems with h.264 found inside mkv wrappers. this will probably throw some light on where your problem is coming from.. http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/ I would use ffmpeg raw command line to change the codec.. to something I know avidemux will cope with... or use one of the mkv toolkit things.