Slowing down playback speed of movies in psychopy

OS MacOS 10.12.6
PsychoPy version 1.86.6
Dear PsychoPy users and developers,
I’m currently trying to implement a relatively simple task with mp4 movies and wondering if you can recommend a straightforward way to slow down a playback speed without reformatting the files in an external software. My movies have duration of 1s and I’d like to play them 4 times slower. Changing duration of a stimulus in the GUI does not seem to help. Neither was I able to figure out how to do that the code. Any suggestions?
Many thanks for your time!

Regards,
Alex

Hi Alex, in code, you can explicitly draw individual frames and pause and restart the video. So I’d suggest setting up the movie component in Builder but don’t give it an explicit start or end time. Then in code, you would only move to a new frame on every 4th screen refresh. Builder keeps track of the current screen refresh number in the trial (a variable called frameN), so we can check if the current screen refresh is evenly divisible by 4 (frame 0, 4, 8, etc) and update it only then.

Insert a code component. In its “Each frame” tab, put something like this:

if frameN % 4 == 0: # if no remainder when dividing by 4
    yourMovieComponentName.play() # advance to next video frame
else:
    yourMovieComponentName.pause() # stay on the current video frame

# draw the current frame to the screen:
yourMovieComponentName.draw()

Untested. Let us know if it does/doesn’t work. In particular I’m not sure if .draw() should only be called after .pause(), and not after .play().

Hi @Michael!
Thanks a lot for your response. I was hoping that there’s an explicit parameter determining playback rate (something like ‘movie.PlayRate’), but it doesn’t seem to be the case, unfortunately.

When I try to implement your solution by putting your code into 'movie’s ‘each frame’ box, I get the following error:

movie.play()
^
IndentationError: expected an indented block

Here’s a working example with 5 stimuli (1s each):
https://www.dropbox.com/s/y6hx3smy7i59jmw/VidExample.zip?dl=0

If you have a simple solution in mind and assuming that’s not much of a bother, I would really appreciate your help.
Thanks again!

Best,
Alex

Spaces in Python code are important and have meaning. In the code I gave above, two lines are indented by exactly four spaces. You need to preserve that spacing for Python to understand what is going on. i.e. Without the spaces, Python can’t tell what code is executed only under the if clause and what code only under the else clause.

Python was even nice enough to have given you the exact error message you needed to identify and correct the issue (“IndentationError: expected an indented block”, with even a pointer indicating the exact position of the problem). Googling such error messages will help you learn your way around.

Alright. I did not manage to make it work and ended up freezing last frames with seek(). Thanks anyways.