psychopy / psychopy

For running psychology and neuroscience experiments
http://www.psychopy.org
GNU General Public License v3.0
1.67k stars 901 forks source link

[Bug]: Webcam camera component does not work #6857

Open j-ales opened 2 weeks ago

j-ales commented 2 weeks ago

PsychoPy Version

2024.2.1

What OS are your PsychoPy running on?

macOS Silicon

Bug Description

The webcam component does not work to save files on OSX when using the OpenCV or ffpyplayer backend.

Appears to be related to missing moviepy dependancy, there is also appears to be logger format string bug that comes after the missing dependancy error. See error message below.

The intermediate audio and video files are saved and left in the main directory.

Expected Behaviour

Saving movie files and putting them into the appropriate data location.

Steps to Reproduce

  1. Add camera component to trial
  2. run script
  3. view runner output

Additional context

Error message:

run( File "/Users/ales/tmp/tesst_cam/test_cam_lastrun.py", line 641, in run cam.save(camFilename, encoderLib='ffpyplayer') File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/hardware/camera/init.py", line 2337, in save movietools.addAudioToMovie( File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/tools/movietools.py", line 1016, in addAudioToMovie from moviepy.video.io.VideoFileClip import VideoFileClip ModuleNotFoundError: No module named 'moviepy' Exception ignored in atexit callback: <function flush at 0x1133201f0> Traceback (most recent call last): File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/logging.py", line 321, in flush logger.flush() File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/logging.py", line 306, in flush formatted[thisEntry] = self.format.format(**thisEntry.dict) ValueError: Unknown format code 'f' for object of type 'str' Exception ignored in: <function _Logger.del at 0x113320550> Traceback (most recent call last): File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/logging.py", line 254, in del File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.10/psychopy/logging.py", line 306, in flush ValueError: Unknown format code 'f' for object of type 'str'

mdcutone commented 5 days ago

Yes this seems to be due to the missing moviepy dependency mostly. We're looking into the other issues that come up after the first error.

For context, we use moviepy to composite the video and audio recordings to create the final output movie file. That is done when the recording complete, so that's why we're seeing the error after the recording is done here. I'm assuming the video and audio tracks are being properly obtained.