In my experiment (Win10, version 2020.1.1) I play a series of video clips separated between blocks (super basic code), all mp4 format. There are 3 types of blocks: audio-only blocks (which are technically audiovisual but with a black screen I placed in the video-editing software to replace the talking head), video-only blocks, and regular audiovisual blocks.
The problem – sometimes an “echo” appears with the audiovisual clips: The clip plays normally and then, in the end, the last 2-3 words of the sentence will suddenly repeat. This repetition is in the auditory modality only! (the visual component will keep playing normally). This happens at random and not with specific clips (so it’s not a problem with the file) and does not happen every time. It only happens with the audiovisual clips but not with the auditory-only clips (which, as mentioned, are basically the same in every parameter I can think of – e.g., when exporting from the video editing program I export both audio and video).
I have absolutely no idea what the problem can be, don’t even know where to begin…
I’d very much appreciate your help guys!
Thanks
Maya
This sounds a bit like two copies of the video are playing. Only one would be seen on screen but the second can be heard when the first one finishes. Is that possible?
Hey - thanks for picking up on this.
I’m running it locally and I’m using the builder, so I’m not sure whether the code is reproducible, but it should be the part below. It’s inside a loop called “trials1”, and following the videos there’s another routine with questions about each video (inside the loop). (There’s another loop (“showvideo”) just around the videos, but that one doesn’t do anything atm.
Let me know if you need any more information. Thanks!
------Prepare to start Routine “Video”-------
continueRoutine = True
# update component parameters for each repeat
movie = visual.MovieStim3(
win=win, name='movie',
noAudio = False,
filename=video,
ori=0.0, pos=(0, 0), opacity=None,
loop=False,
size=(1200,900),
depth=0.0,
)
# keep track of which components have finished
VideoComponents = [movie]
for thisComponent in VideoComponents:
thisComponent.tStart = None
thisComponent.tStop = None
thisComponent.tStartRefresh = None
thisComponent.tStopRefresh = None
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
VideoClock.reset(-_timeToFirstFrame) # t0 is time of first possible flip
frameN = -1
# -------Run Routine "Video"-------
while continueRoutine:
# get current time
t = VideoClock.getTime()
tThisFlip = win.getFutureFlipTime(clock=VideoClock)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *movie* updates
if movie.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
movie.frameNStart = frameN # exact frame index
movie.tStart = t # local t and not account for scr refresh
movie.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(movie, 'tStartRefresh') # time at next scr refresh
movie.setAutoDraw(True)
# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
core.quit()
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in VideoComponents:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
# -------Ending Routine "Video"-------
for thisComponent in VideoComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
movie.stop()
# the Routine "Video" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()
thisExp.nextEntry()
# completed showvideo repeats of 'showvideo'
By code or component I actually meant a screenshot of your movie component (any tabs where you have made changes to the default) rather than code created automatically from it. It looks like you are setting a movie component called movie in a routine called Video as the contents of a variable called video every repeat (which I assume is a column in your spreadsheet). I also assume that your experiment is set to use pixels.
Is the issue that you are getting two copies of the audio track?
Do you have any code components within the loop, or any other components that could produce a sound other than movie?
So basically I’m loading a video from a spreadsheet and then asking the corresponding question.
Regarding my issue:
The video plays perfectly fine and the audio is correct, right until there is only one second remaining. For the last second, it glitches back: The video keeps running, but the audio jumps back a second. (For example, for a video that is 20 seconds long, everything is fine until second 19, but then for the last second, you hear the sound that belongs to second 18 while seeing the correct video).
There is an additional code element in the loop trials1, because for some videos, I want to ask two questions. In these trials, the variable video is called “LEER” (meaning empty in German), showvideo is set to 0 and no video is shown, but we jump directly to the question.
The videos work fine when played in VLC, yes. I’ve tried converting them to different formats (like mp4), but the same problem occurs.
Regarding the backend setting, moviepy is the only one that works at all, the others let the experiment terminate before the first movie, giving me various error messages such as
“AttributeError: module ‘vlc’ has no attribute ‘CallbackDecorators’” (for VLC)
“AttributeError: module ‘vlc’ has no attribute ‘dll’” (for opencv)
" avbin.dll failed to load. Try importing psychopy.visual as the first library (before anything that uses scipy) or use a differentmovie backend (e.g. moviepy)." (vor avbin).