The end of a video segment is marked by the first frame following it.
Hence, the end of the video should be marked by a dummy frame following it.
That frame should be a key frame and display "THE END (extra dummy frame)".
Doing so would drastically simplify the logic of AviDemux.
It would dispense with gentle lies too.
If Avidemux is at the end of a 1500 frames video, it displays "at 1500/1500".
The last frame is in fact frame 1499.
Frame 1500 is the dummy frame and it shouldn't display an image.
If you jump from key to key frames, you never reach the end of the video.
Except if the dummy frame is a key frame.
Such logic usually removes several +1, -1 and ifes from the code.
Everything looks like clutching in place.