Iteration count in video loop

Hi all,

I am coding in PsychoPy 3.2.2 on Windows 10 using a G-SYNC 120 Hz monitor.

I am trying to display videos in 40 fps, each 1700 ms long (= 68 frames in each video). I am using this loop to show the videos (these are visual.MovieStim3 in an array):

    # loop over video array
    for x in range(len(trialArray)):

        # collect number of frames in video loop
        framecount = 0

        # start time for measuring video duration
        video_starttime = core.getTime()
        # show video and stimuli
        while trialArray[x].video.status != visual.FINISHED:
            # draw video

            # draw monitors

            # draw images
            # start recording frame intervals
            if trig:
                win.recordFrameIntervals = True
                trig = False
            # add 1 to framecount
            framecount = framecount + 1
        # get measured video duration
        video_duration_measured = (core.getTime() - video_starttime)

        # get video duration per definition in file
        video_duration = trialArray[x].video.duration
        # get mean frame interval
        win.recordFrameIntervals = False
        mean_frameinterval = np.mean(win.frameIntervals)

The video_duration_measured variable shows me that the while loop takes approx. 1.7 sec, which is fine. But I am irritated by the framecount variable. I thought each frame-change of the video should be represented by another iteration of the while loop, this is why I would expect the framecount variable to be 68. But actually this is not the case and the iteration count differs a lot from trial to trial (70-101) but is never 68. Maybe I am not understanding the functionality of this while loop correctly. I would be happy if someone has deeper insight into what this while loop does and could help me explain this observation.

Thanks a lot and have a nice day!