't' not recording correct duration of videos

Hello,
I am creating an experiment where I present participants with some videos. In every trial, I record the duration of the videos using the following line of code:
thisExp.addData(‘expDurRecord’,t) in the end routine part of the routine where I present the video,
where t = movie_stimPlayClock.getTime()

however, when I compare the ‘expDurRecord’ with the actual durations of the videos, I see some serious inconsistencies (e.g., the duration of the video is 3.5 seconds but expDurRecord saves 5.3 seconds etc).
can anyone tell the reason of these kinds of incosistencies? this is quite important for me.

thank you very much in advance, tutku

Hi There,

Just to check, are the only components in your routine are the movie and code component and does your movie component force the end of the routine?

Thanks,
Becca

I’m interested in the answer here too but I’m wondering whether t includes the time to load the video at the start of the routine.

becca,

the answer is yes.

wakecarter,

I encountered the same issue in an experiment where I simply draw a polygon and wanted to record its duration, but there were lesser numbers of inconsistencies (1 out of 200, but it was there still). so, i dont think that the problem is specific to the videos.

Hi, Do you have the “save onset/offset” times in the data field selected? If so does that timing seem more consistent with expected ?

Thanks,
Becca

I might be misremembering but I didn’t think that worked online.

At the moment I was interpreting the question as running in builderview offline. Tutku please could you confirm?

yes I was working on it offline on builder mode. though the problem persists in online mode. I “solved” the problem by drawing the video durations from the excel file explicitly. but it doesnt really answer my question why builder (or pavlovia, because I encountered the problem in online mode as well) does not record the t as the video duration but it seemingly records something else.
I dont understand why i need to draw the video durations explicitly while the videos already are the exact durations long that I want them to be. but yeah, explicitly calling for durations from the excel file solves the problem of inconsistent t records.

t is a reserved variable name: Builder automatically assigns it at the start of each frame to the current time in seconds since the start of the routine. So if you re-assign another value to t, you are very likely to get unexpected results. Try using another variable name.

Hi Tutku,

I am pleased you found a solution. As I was curious I also made a small variant of what you describe (routine below) where the code component has:

Begin experiment tab:
movieClock = core.Clock()
Begin Routine tab:
movieClock.reset()
End Routine tab:

t = movieClock.getTime()
thisExp.addData('expDurRecord',t)

Interestingly, the reported duration of the video seemed relatively stable here and in line with expected. Did you have any other components like key presses in your routine? are you running mac or windows? how large was the inconsistency with the polygon example you encountered?

Thanks,
Becca