This repo contains code solving the problem: I want to play 2+ different videos at the same time on 2+ monitors using the command line and record using a webcam. This is neccesary for me for some behavior trial I am running.
running a trial
To run a trial, just type in
bash run_IIA.sh. The script prompts the user to input various information. The user tells the program where the program is binary or trinary. If binary, the local computer will run both videos using the
show_vid.py script. The second network computer will record the trial with a webcam with ffmpeg and save it to the disk on the network computer with a name like female_trialType.avi. Take care that the length of the videos and the length of the video being recorded by ffmpeg are the same and that the settings of camera are appropriate using Wecam Settings. If the trial is trinary, then the local computer will play two videos and the network computer will play a third video and record the trial. Whatever the trial, the location of which video is shown on what monitor is randomized. There are various
wait commands both in the bash and python script to ensure the videos begin playing at the same time as the webcam starts recording. Note that using
at are not accurate enough for synching events between two computers.
When the trial is over, the user is prompted to input additional information, and then to verify that all the information she entered is correct. If it is, then the trial is saved as a row in a log file and the file is emailed to me. If the python scripts stop working or the randomization of the videos fails, I get sent an email about the error.
a bit about
python show_vid.py -v1 path/video1 -v2 path/video2 to show one video using two monitors connected to your computer, or simply
python show_vid.py -v path/video1 to show one video using your main monitor--the second argument is optional. The script will throw a fit if you attempt to show two videos when you are connected to a single monitor, or if you've given it a nonexistent video file to read. It creates windows that are the size of your screen, but are (unfortunatly) not fullscreen due to a glitch in psychopy. The script relies on the
Screen class defined in
screen.py which provides a convenient way to link and keep track of the video and window associated with each screen (this only works because I will never have more that on window on a screen).