I'm trying to convert an H264 movie to MPEG2 with TMPGEnc using an Avisynth script as the source. The source was a MKV with ASS subtitles which I demuxed and added to the Avisynth script using TextSub. This is my script:

DirectShowSource("my_filename.mkv",audio=false)
TextSub("my_subtitles.ass")
LanczosResize(704,396)


After about 3 minutes of encoding, I noticed the video and subs were out of sync by about 4 seconds! I thought it was TMPGEnc's problem, so I tried to encode to Xvid instead using VirtualDubMod. Again, same problem. Then I used Subtitle Workshop to check the timing of the sub file and compared it with the original MKV, and it was correct. The problem is that the encoded video is running slower than the source video while the hardcoded subs are running at the normal speed.

I then took off the TextSub and LanczosResize because I thought they were causing a slowdown with the encoding process. Using only the DirectShowSource, the video still experienced the same problem on both MPEG2 and Xvid.

What I find most strange is that when I preview in Avisynth, TMPGEnc or VirtualDubMod, the subtitles and video are in sync like they should be. It's during the encoding process where they go out of sync. Input and output files are both 23.976 FPS.

Anyone know what's going on here?