LABSN / expyfun

Experimental paradigm functions.
BSD 3-Clause "New" or "Revised" License
13 stars 21 forks source link

FIX: Fix bug with video playback #445

Closed larsoner closed 5 months ago

larsoner commented 2 years ago

I used a 4k 30fps and 1080p 30 fps on Linux with:

import expyfun
fnames = ['hawaii_blue_water_4K.mp4', '342572022.mp4']
with expyfun.ExperimentController('test', full_screen=True, version='dev',
                                  session='a', participant='b',
                                  output_dir=None) as ec:
    ec.load_video(fnames[0])
    ec.video.set_scale('fit')
    ec.video.play()
    while not ec.video.finished:
        if ec.video.playing:
            fliptime = ec.flip()
        ec.check_force_quit()
    ec.delete_video()

On Linux, on main:

  1. With fnames[0] (4k) things are a slideshow (1-2 FPS) and I get the error reported in #444
  2. With fnames[1] (1080p) things are smooth (probably the native 30 FPS) and there is no error

On this PR, for [0] I get the same playback but no error, and for [1] I get the same (good/correct) behavior as on main. And even when I set set_scale(0.1), playback is still terrible for the 4k video, suggesting that it's a video decoding/resolution limitation rather than anything having to do with the window/display size on screen (again, at least on my Linux machine!).

@JustinTFleming can you try this branch and see if you observe the same behavior on Windows? (BTW, with bug reports it's usually best to come up with a minimal reproducible example like the above if possible -- it saves devs time and makes sure that everyone is comparing apples to apples, to the extent possible!)

If you do get the same behavior, then I would look into maybe making your videos have a slower framerate or resolution. Closes #444

larsoner commented 5 months ago

Still seems to work okay a couple of years later and tests are green so in it goes!