psychopy.org | Reference | Downloads | Github

Simultaneous Stim Presentation and Webcam Video Capture

Does anyone have any code and/or suggestions on how to present stimuli (just text stim) and simultaneously capture raw video from a USB webcam? Specifically, I’d like to trigger recording from the camera at the beginning of a trial, present some text stimuli, and then stop the video recording after all the text stimuli has been presented.

I tried opening a subprocess calling on ffmpeg to start capturing video at the beginning of a trial and then closing that subprocess at the end of a trial, but psychopy didn’t like that. It ended up not saving the video. The code works when I run it outside of psychopy in a python interpreter, I just can’t figure out how to integrate it with psychopy to play nicely.

I’m also open to using something other than ffmpeg if others have had success (cv, maybe?) doing something like this in their own experiments.

Thanks,
Dan

http://www.psychopy.org/recipes/webcam.html