Hi,
I am using Windows 11 and the latest PSychoPy version (v2024.1.4). While participants watch a 180 sec video on the screen I want to record their facial expressions. The video component and the code component are part of the same routine. After 180sec the video component force ends the routine. This is the code:
(Begin experiment)
import cv2 as cv
webcam = cv.VideoCapture(0)
fourcc = cv.VideoWriter_fourcc(*'mp4v')
filename = u'data/RECORDING_%s_%s_%s' % (expName, expInfo['participant'], expInfo['date'])
out = cv.VideoWriter('OUTPUT.mp4', fourcc, 20.0, (640, 480))
(Each frame)
while webcam.isOpened():
ret, frame = webcam.read()
out.write(frame)
c = cv.waitKey(1)
if c == 27:
break
webcam.release()
out.release()
cv.destroyAllWindows()
The video is recorded and saved into OUTPUT.mp4. However, the experiment just stops. That is, the 180sec video is not shown, presumably because Psychopy is busy recording the video (which works fine until I ESC the experiment; then it is saved) and the experiment is not continued as planned. I want to run the code and record the video in the background as long as the routine is current. This would result in a 180sec recorded video.
Thanks in advance!
Sebb