Sorry I mistook you for another user whose name has a similar length and cadence.
Still, questions for custom code don’t belong in general help.
Your out times are probably wrong. The total duration equals the sum of its parts. The out is not equal to in + duration in MLT XML. out refers the time of the start of the last frame. Using frame counts duration = out - in + 1.