Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Randomised sound loop simultaneously with separate video


I've run into a bit of a problem as I need to get opensesame to play a 1.5 minute video while a stream of 420 sound files play in random order in the background. I'm not sure how to do this, as I can't get it to work with the coroutines function. I also can't just edit the video outside of opensesame to have the sound files playing in it, as I need the order of the sounds to be randomised for each participant. Most likely I'll have to do some scripting to make this work, but I'm not very good at writing inline script, so I'd be very grateful if someone could point me in the right direction of how to get started.

Thank you!


  • Hi Hannah,

    Yes, I am afraid you need to do some inline scripting. Following advice:

    1) For video presentation, use OpenCV2:

    It is a quite straightforward python library to interact with videos (Note: you need to install it first!)

    2) Use a while or for loop to playback the sound files

    Before the loop you can randomize and load them. In the loop just play them one at a time.

    3) Learn coding 😀

    The beginning might be a little tough and slow, but it is definitely worth the investment. It will make your life much easier in the future and usually you also start to understand better what is actually happening in your experiment.

    Try to get started on that, but once you get stuck don't hesitate to ask a question here (the more specific the better)


  • edited February 11

    Hi Eduard,

    Thanks for your help. I am already in the process of learning how to code so I do know how to code some and have already written some inline script for other parts of my experiment, but I’m just not very good at it and tend to make mistakes that take a long time to solve. Hence I was hoping someone could let me know a rough skeleton of how to go about coding this part as I need to finish the experiment on a very short deadline.

  • HI again Eduard,

    I've tried using OpenCV2 but the video doesn't play, and I just get a blank screen that lasts for a few seconds before it says that the experiment has finished successfully.

  • Hi,

    What have you tried. If you need help, please provide the code that causes the problem. Otherwise I can't really do much. (And please also a little video that I can try running!)


Sign In or Register to comment.