OS: Win10 64-bit
PsychoPy version : 3.1.2
Standard Standalone?: Y
What are you trying to achieve?:
I am recording participants with a webcam as they complete a psychopy experiment. I need to be able to synchronize the recorded video and the psychopy output so that I know when (in video time) certain events occurred in the experiment.
My plan for this is to do both the webcam recording and the psychopy experiment on the same computer. Then I can hopefully get the system clock and compare the offset from when the webcam started and when the psychopy experiment started. The system time when recording starts is already written to the video metadata, so I just need to add a precise system time when the experiment starts to psychopy output.
What did you try to make it work?:
I compiled my experiment from Builder as a script and added the following at the top near the other imports:
from datetime import datetime
Then I added the following to the section where the experiment session info is stored:
expInfo['time'] = datetime.now().strftime("%H:%M:%S.%f")
When I run the experiment, a nice column is added to the output containing a timecode that is in the expected format. It seems plausible that this timecode is the system time at experiment start (the H and M is the same) but it is hard to know for sure whether the seconds and especially the fractions are correct (and these are important for synchronization with the video).
What specifically went wrong when you tried that?:
Above is my attempt at solving this problem and I think it looks reasonable, but I’d appreciate it if people who know more about python and psychopy could confirm whether this is a good approach and if you have suggestions on improving it.
Specifically, can someone confirm that running
datetime.now() right after
data.getDateStr() will return the same timestamp used to calculate the relative time in
core.Clock()? Or is there something relevant already built into psychopy that I am not aware of? Thanks in advance.