FFMpeg cuts off the ending of some movies

Im having a problem converting avi files to mp2. For the most part my script works fine, but some files (especially long movies) will come out with the end cut off.
Specifically, the last avi it did that with was 2:23 long, but the resulting mp2 was only 1:49 long.
The script uses 2 pass encoding and I set the filesize to fit on a standard dvd. However, for some reason instead of shrinking the movie to fit, it just cuts it off when it hits that filesize.
Using ffmpeg v 2.4.6-2 on a laptop with a single core processor running fedora 21.

How can this issue be duplicated?
Does it occur with just one pass?
What are you using to determine the durations?
What does ffmpeg say about the output durations? ffmpeg -i input1 -i input2
Most importantly, can you provide the complete console outputs from your commands?

I havent figured out a common factor that causes it, except maybe large file size/hd video. All the movies I convert are usually avi/ac3. So the only way I can duplicate is to encode a large file with these settings, though not all of them do it. Usually only one in 10 or 12.
From what I have tried, if I dont use 2 pass then filesize cap wont be enforced, and it comes out huge.
I use the log file (as well as using vlc player to test input and output) to determine durations.

Please use the code button to format your commands and console outputs.

I should have looked more closely at your second-pass command. It contains this:-fs 4680000000

Which means the encoding will stop once the output reaches 4680000000 bytes. If you want it to fit a DVD then you have to do some math (unless -target ntsc-dvd handles it...I don't recall):bitrate = file size/duration
Or more specifically (source):video bitrate = (target_size_in_Mbytes - sound_size_in_Mbytes) * 1024 * 1024 / length_in_secs * 8 / 1000

thanks for your answer. that explains why its doing that. I took out fs and put in some code that does that math automatically for each file. I set the target size for 36000000 which is around 4.45gb (I couldnt use exactly 4.6gb cuz the -b:v option sets an "average bitrate" and some files go a little over dvd size to 4.9)
I use async to dynamically sync the audio. Had a few sync problems and this fixed it. The scale filter included in this code will take a video of any aspect and proportion/pad it to show properly in a dvd player without skewing or stretching.

Someone may find this code useful as it will take essentially any input video and produce a good looking properly padded dvd compatible mpeg2 with the audio syncronized (assuming the input file is in sync, of course). And now it will properly fit a dvd disc without cutting the end off.
Note: it pipes the console output into an encodelog in your home Videos folder.
thanks again for your help. :)