Movie freezing at the end

Hi all,

I am using v2022 1.3 and have an experiment where I need to play videos one after the other. This occurs in two routines. The first routine has 6 videos, the second routine has 24 videos. Each video is maximum of 5 seconds long and is accompanied by audio.

The issue I am having is that the visual in the videos freezes at the end, whilst the audio continues. I would like the videos to play smoothly as they do outside of PsychoPy.

I have tried the videos in MP4 and AVI, as some videos are repeated, I have tried copying and saving the repeated videos under different names. I have also tried leaving a longer gap between videos, adjusting the size of the videos to 1280 by 1024 pixels but none of this has fixed the issue.

I am using a laptop, but I have tried the desktop in the lab and there is the same issue.

Any advice would be greatly appreciated.

Thank you,

Amanda

Hi @AJM,

Would you mind attaching your .psyexp file here for me to take a look at?

Thanks!

Kim

Novel_word_vs3.psyexp (31.3 KB)
Hi Kimberley,

Thank you for your response. I have attached the file, hopefully you can view it okay.

Many thanks,

Amanda

Thanks @AJM,

I’ve just taken a look at your file, thanks for attaching it.

Does the attention_getter video have a set length that can be input? I’m asking this because after 11s into a trial there are two video components running at once. This could cause some issues with processing speed. So if the attention_getter video is, say 10s long, inputting the duration as 10s as shown here might help with the freezing issue:

Thanks,

Kim

Hi Kimberley,

Thank you for your prompt response. Yes it does. I shall try that and let you know how I get on!

Thank you :slight_smile:

Amanda

Hi Kimberley,

Unfortunately that did not work :pensive: Is there anything else you can think of that I could try?

Many thanks,

Amanda

Hi @AJM,

One other thing you could try is pre-loading your videos during an ISI component (find out more here). I’ve added an example for you during your salience trials in this file:

Novel_word_ISI_example.psyexp (32.2 KB)

So now the videos are pre-loaded before they are presented, which may help with the lag.

Let me know how you get on!

Kim

Hi Kim,

Thanks for this. Unfortunately the videos are now not playing with the ISI. The error message says ‘attention_getter’ is not defined. When I remove the ISI the videos still play. Is there something else I should be doing? Everything in the link you sent seems to be covered.

Thanks,

Amanda

Hi @AJM,

Would you mind attaching that version of your .psyexp file here?

Also, as a slight side note - are you able to separate the audio and visual parts of the movie file at all? So that you have the sound and the visuals for the movie in two files rather than together as one?

Thanks,

Kim

Hi Kim,

It was the file you sent back to me. It starts off okay with the text, but when it gets to the ‘static’ it gives this error: salience_trialComponents = [attention_getter, salience, load_video]
NameError: name ‘attention_getter’ is not defined .

Yes I have the audio and video as separate files as well. Shall I try them instead of the one video file?

Thank you!

Amanda

Hi @AJM,

Ah - I think that error might be because the conditions Excel file and other resources that the experiment needs might not be in the same folder as the .psyexp file. If you could place my updated .psyexp file in its own folder, and copy and paste all of the Excel files etc into that folder with it, it should run.

Great! Yes, do try that and see how that goes. For the visual only part of the file, just ensure that you check the ‘No audio’ option in the ‘Playback’ tab of the movie component.

Do let me know how you get on!

Kim

Hi Kim,

I am really not having much luck!!

Moving all the files into one new folder did not work, I could only get PsychoPy to run if I changed the file to ‘set every repeat’ rather than with the ISI setting.

With regards to the video with no audio, I am having real trouble getting this to work and getting the video and audio to play simultaneously. Do I want the audio and video in the same routine or different routines with a loop? I have tried both and neither seem to be working. Is there a preferred format for the audio? Yesterday I could only get WAV to work, but today my computer doesn’t seem to like that and won’t play it even when I try it alone (without trying to pair with the video).

Sorry for so many questions, as you can tell I am a novice!!

Thanks again for your help,

Amanda

Hi @AJM,

Please don’t apologise - questions are really helpful!

Okay, let’s forget the ISI for now and focus on separating the audio and visual parts of the video. So, let’s assume that we’re starting from the first experiment file (Novel_word_vs3.psyexp) that you sent and that we want to split the salience video in the salience_trial routine into visual and audio:

  1. Click on the salience video component that’s already in that routine, click on the Playback tab, and check the ‘No audio’ box. This gives us the visual only part of our file:

  1. Now, add in a sound component (found in the Stimuli component drop-down) and set the start time and duration of that component to match your salience video component. Now, set that sound to be the sound file from your salience video clip. As for the .wav files not working - PsychoPy definitely supports .wav files but if you ever want to move this study online then you’ll want to use mp4 format. It might be worth re-splitting your sound files from the video files. You can do this fairly easily using a free download such as Audacity etc.

Try this out with just this first video to begin with. If it works just repeat these steps for all other videos in your experiment. Another user has had success straight away by splitting the visual and audio files, but one user has had to offset the sound component so that the audio syncs up with the visuals. Do let me know how you get on by separating them first, then we’ll talk about offsetting if we need to!

Thanks,

Kim

Hi @Kimberley_Dundas ,

Thanks for the information.

The good news is I can get the sound and non-audio video to play together (and the video is not lagging!!) - however, I have three different videos for the salience trials and each has a different audio. So whilst I can individually set up a routine for each of the three pairings, this is not ideal. I am trying to work out how to create a loop, previously I had this for the videos (so the order was random, with an attention grab between each one) but now there are two stimuli I am struggling. I tried adding another column to the Excel spreadsheet for the audio (not sure if that was the right thing to do) and have changed the speed rate on each audio to be the same. However, I keep getting this error:

SoundFormatError: Tried to create audio stream 48000_2_128 but 44100_2_128 already exists and win32 doesn’t support multiple portaudio streams

This error even occurs when I put the same audio file in each cell on Excel.

Any ideas?

Thanks again for your time!

Amanda

Hi @AJM,

Great news, I’m glad that part worked!

You are absolutely correct in your approach. Add in the extra column for the audio file to your conditions spreadsheet, then just make sure each row has the corresponding video and audio files in. So, row 1 of your spreadsheet would have ‘video1’ and ‘audio1’. This will ensure that the correct audio is chosen for the video. Then, for your sound file you would just put $audio or whatever your column header is.

The good news regarding your error, is it’s very easily fixed! What’s happening (I think) is PsychoPy is trying to add in as many default settings as possible to the audio stream when it initialises, as this will save time later on. But, this means that when we want it to look in a conditions file for our sound it doesn’t ‘know’ what your sound will be just yet. So it puts in the default note of an ‘A’ tone. Now this is fine, but the ‘A’ tone has a different sample rate (44100Hz) than the sound you want to play (which is sampled at 48000Hz), resulting in your error.

Now, to fix this there are a couple of things we can do but by far the easiest is to resample your audio file to be 44100Hz. Again, the free Audacity software download can do this quickly and easily (documentation here if you need it).

Let me know how you get on with this, it sounds like you’re very close to being fixed!

Kim

Hi @Kimberley_Dundas ,

Thank you for the link with regards to changing the Hz. I had tried to do it previously, but had not done it correctly.

I am pleased to report that I now have the study working with the video and audio separate. This has definitely made a big improvement on the lagging and freezing at the end.

Thank you very much for all of your time and patience in helping me.

Amanda

1 Like

Hi @AJM,

I’m so pleased this helped! I’ll mark my response as the solution so that other people can try it out if they’re struggling with the same problem.

Happy experimenting!

Kim