OS: macOS Tahoe 26.0.1 (Pro M2 chip)
PsychoPy version: v2024.2.4, python version
Standard Standalone Installation? (y/n): y
URL of experiment: https://run.pavlovia.org/avisha/trial
Do you want it to also run locally? (y/n): n
What are you trying to achieve?: record participant’s videos while they do the experiment (watch short movies).
What did you try to make it work?: Experiment is working. I have a welcome routine (fixed duration of text displaying for 10 seconds), trial (movie and camera component, camera’s duration has been set to 478 seconds, which is movie’s duration + 1 second, movie duration is not set to anything, and forced end of routine has been enabled for movie), then wait routine of text displaying for fixed duration of 5 seconds, then trial2 routine of text displaying for 10 seconds and camera recording for those 10 seconds both durations fixed, then end routine for text displaying for 10 seconds.
What specifically went wrong when you tried that?:
Problem 1:
In the trial routine (contains both a camera and a movie component):
-
Movie file duration = 477 seconds. Camera component duration I set to 478 seconds, and the final recording is indeed 478 seconds.
-
However, the trial routine duration (per .csv) = 480 seconds.
-
How do I align the camera recording (478 seconds) with the movie playback since I only see the routine start/stop in the output (480 seconds). Without actual onset/offset logs for the movie, it’s unclear where buffering or delays occurred.
**Problem 2: **
After the above routine trial which had the camera recording, next routine wait was supposed to display a text for 5 seconds.
-
However, there was a message on the screen after the last routine saying ‘please wait for a few moments while the video uploads to the server…”.
-
wait routine: set to display for 5 seconds, but in the saved .csv file it shows up as ~0.1 second (according to wait.started, wait.stopped)
-
trial2 routine (with a camera component): supposed to last 10 seconds, but the .csv shows 14.5 seconds. It feels like the missing 5 seconds from wait carried over here.
-
wait routine (camera component): camera duration set to 10 seconds, but the recording is only 9 seconds.
-
end routine (no camera): supposed to last 10 seconds, but only lasted 7 seconds.
Problem 3: Missing onset/offset columns
Even though I enabled “Save onset/offset times” for the movie component, the final .csv does not contain those columns. Instead, it only shows the overall start/stop time of the routine.
*Ultimately, I need to include a total of 4 movies (each 8–12 minutes long) along with camera recordings for each. How can I optimize the experiment to avoid timing issues, minimize buffering effects, and ensure that routines following a camera-recording routine are not affected while data is being uploaded to the server?
*
Minor problem: Because I’m using a MacBook Pro with an M2 (Apple Silicon) chip, the camera component doesn’t work locally — PsychoPy doesn’t get permission to access the camera. Is there any known fix for this?
Dear Avisha,
I’m not that familiar with the movie component and why it’s not working correctly. However as a way to debug it, and maybe just use this option as the main timing method (for peace of mind), you can try creating a code component that sets a variable as true 1s into the trial routine. Then for the start time of the movie component you would have it based on condition (referring back to that “True” variable”. Then the stop component can forced end of routine, or code component that is based on the routine timer (then doing the same conditional statement for the stop timing).
Are you sure there is not any weird rounding of the video playback file length (might be 477.8 or something)?
In reference to onset/offset log issue, there is a fix in this thread: Onset and offset timestamps for videos - #13 by alicealbertinidrew and here Onset/offset times of the video stimuli are not saving .
For your problem 2 you state that you have your 5 seconds of text AND a camera component that is 10 seconds. However in your first paragraph you state that the camera component is in trial2 (which is 10 seconds long). Maybe that’s the issue there?
Issac
Hi Issac,
Thanks for your response!
The exact duration of the movie is 477.269000 sec. Maybe I can round the routine duration up.
Putting aside the onset/offset timing issues of movies, how do I fix the camera component buffering issues? The wait routine after trial was supposed to run for 5 seconds but ran for less than 1, and then the trial2 routine after wait was supposed to run for 10 but ran for 14ish.
Camera component is both in routines ‘trial’ and ‘trial2’. I have attached pictures for demonstration.
‘trial’ routine:
‘wait’ routine after ‘trial’:
‘trial2’ routine:
Here is the .csv file of this run, from which I examined all the timing issues.
651962_trial_2025-09-30_19h01.50.263.csv (783 Bytes)
I did another run of the experiment, got similar results as before. Here is my theory of whats happening- **
Camera 1 upload time** = wait.started – trial.stopped
Camera 2 upload time = end.started – trial2.stopped
Reasoning:
-
wait.started should have occurred immediately after trial.stopped, but instead there was a delay.
-
Also, wait.started – wait.stopped should have been exactly 5 seconds.
-
Instead, it was <1 second, which suggests the missing time was spent uploading Camera 1’s recording.
-
trial2.started – trial2.stopped should have been ~10 seconds, but was ~15 seconds.
- This extra 5 seconds seems to be the leftover from the shortened wait period being carried over.
-
After trial2.stopped, there was another delay before end.started.
- This delay reflects the upload time for Camera 2’s recording.
-
Finally, end.started – end.stopped should have been ~10 seconds but was ~8 seconds.
- The missing ~2 seconds matches the upload time for Camera 2, which likely carried over into this routine.
Dear Avisha,
The way psychopy works, components don’t carry over between routines. As the objects for specific routines are only loaded in their respective routine.
Also try setting your movie duration/end time to match the duration of the video, instead of just letting it play forever and end the trial when the video is finished (so try 477.3 seconds).
Are the time comparisons based on the global clock? If so, maybe adding in a more specific check to verify that the delay is the camera data upload time. Maybe something like:
thisExp.addData('data_upload_start', globalClock.getTime())
#Whatever the code for uploading the camera data is#
thisExp.addData('data_upload_end', globalClock.getTime())
This might give you a better idea of what is going on, but I am not sure how the camera data is being handled, saved, and uploaded, so maybe not?
Have you also tried just setting the “wait” routine to something like 30 seconds? So the camera has more time to upload if that is indeed the problem? Or maybe add the upload time/“wait” at the end of the trial? So when the camera is done recording, it will start uploading the camera data to psychopy when it is done within that trial during the 30 seconds or so at the end of the trial.
Issac
Here’s a cleaner, shorter version:
Thanks. I added time stamps and extended the wait routine to 20 seconds so the camera recording doesn’t affect the next trial. I ran the experiment several times, and the wait routine still lasts only about 2–3 seconds, both in the PsychoPy data and on my stopwatch.
This works for now, but it would be better if the camera component could pause the start of the next routine until recording is finished.