MovieStim3 Issues

692 views
Skip to first unread message

Kris McCarty

unread,
Jan 11, 2016, 2:13:55 PM1/11/16
to psychopy-users
Hi all,

I'm having some real trouble getting stuff sorted for playing back some simple videos in PsychoPy with all versions of MovieStim, i'll start with MovieStim3 as its the most current, I believe it must be format trouble or some such and i'd greatly appreciate your help.


I have the following test code to pull some videos from a folder and display them. The videos are .mp4 encoded in h.264 and when I initially ran this, psychopy downloaded ffmpg32.exe. I also downloaded the OpenCV and VLC

from psychopy import visual, core, event, data, gui
from numpy.random import shuffle
import glob

# Window 
win = visual.Window ([1024,768], fullscr = False, units = 'pix', color = 'black') 

conditions4 = glob.glob('innateVid/*.mp4')
conditions5 = glob.glob('learnedVid/*.mp4')

# Video

vid = visual.MovieStim3(win, filename = 'C:\Users\krist_000\Dropbox\PostDoc Northumbria\Programming\Sam Fletcher\innateVid\caving trimmed.mp4', size = 640, pos=[0, 100])


for i in conditions4:
    vid.loadMovie(i)

    while vid.status != visual.FINISHED:
        vid.draw()
        win.flip()
        if event.getKeys(keyList=['escape','q']):
            win.close()
            core.quit()


I get a really weird error I don't know where to start with, its like it expects the length to be one thing and find the videos length another perhaps?:

##### Running: C:\Users\krist_000\Dropbox\PostDoc Northumbria\Programming\Sam Fletcher\TestScript.py #####
Traceback (most recent call last):
  File "C:\Users\krist_000\Dropbox\PostDoc Northumbria\Programming\Sam Fletcher\TestScript.py", line 21, in <module>
    vid = visual.MovieStim3(win, filename = 'C:\Users\krist_000\Dropbox\PostDoc Northumbria\Programming\Sam Fletcher\innateVid\caving trimmed.mp4', size = 640, pos=[0, 100])
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.83.03-py2.7.egg\psychopy\contrib\lazy_import.py", line 120, in __call__
    return obj(*args, **kwargs)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.83.03-py2.7.egg\psychopy\visual\movie3.py", line 121, in __init__
    self.loadMovie(self.filename)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.83.03-py2.7.egg\psychopy\visual\movie3.py", line 168, in loadMovie
    self._audioStream = sound.Sound(self._mov.audio.to_soundarray(),
  File "<string>", line 2, in to_soundarray
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\audio\AudioClip.py", line 114, in to_soundarray
    chunksize=buffersize))
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\numpy\core\shape_base.py", line 230, in vstack
    return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\audio\AudioClip.py", line 81, in generator
    buffersize=chunksize)
  File "<string>", line 2, in to_soundarray
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\audio\AudioClip.py", line 127, in to_soundarray
    snd_array = self.get_frame(tt)
  File "<string>", line 2, in get_frame
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\audio\io\AudioFileClip.py", line 71, in <lambda>
    self.make_frame =  lambda t: reader.get_frame(t)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\audio\io\readers.py", line 196, in get_frame
    "but len(buffer)=%d\n"%(len(self.buffer))+ str(error))
IOError: Error in file C:\Users\krist_000\Dropbox\PostDoc Northumbria\Programming\Sam Fletcher\innateVid\caving trimmed.mp4, At time t=11.34-11.73 seconds, indices wanted: 100000-117292, but len(buffer)=117124
index 117124 is out of bounds for axis 0 with size 117124


if I change to moviestim2 it either works but the sound is delayed video on video (so sound from video one replays on video 2 etc) almost like a buffer is not flushed or something

 or, it  throws an error '( TagLib: MP4): No audio track
TagLib: MP4: No audio tracks' if the video didn't have sound to begin with (which one or two of mine don't)..


Any ideas folks?

Kris

Jonathan Peirce

unread,
Jan 12, 2016, 5:27:58 AM1/12/16
to psychop...@googlegroups.com
Thanks Kris,

I'm keen to work out why this didn't work with MovieStim3 in particular. My guess is that the audio is in a format that it doesn't recognise but it would be nice to detect that and report it.

For info (you may know this already though) mp4 and mkv formats are really just wrappers around a video stream and an audio stream and those streams can be en/decoded by different codecs. A common one for audio is to use AAC compression and we can't (legally) decode that. VLC might well provide a codec for that which would explain moviestim2 working to a degree.

So you could try outputting movies with 'linear' audio instead of AAC. If you could sned me (off list) one of the files that is giving you the message below I'd like to take a look though too.

For movies that don't have audio I did fix one error already in 1.83.03. What version are you running?
http://www.psychopy.org/changelog.html#psychopy-1-83-03

cheers
Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/ee82cbd8-281a-4c8c-9d59-abbde7e31e9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Jonathan Peirce
University of Nottingham

http://www.peirce.org.uk


This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it. 

Please do not use, copy or disclose the information contained in this
message or in any attachment.  Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.

This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.

Kris McCarty

unread,
Jan 12, 2016, 8:57:47 AM1/12/16
to psychopy-users

Hi Jon,

 

Thanks for the prompt reply.

 

It seems you are mostly right on the video format. I converted these vids to .avi with MP3 audio (as for some reason I couldn’t selected uncompressed or PCM in my conversion software) and the majority of videos worked just fine under MovieStim3. That said there was one video (that I will send to you) which, even though it was encoded the same, still threw that out of bounds error that I described above. This was using Windows7 with PsychpoPy 1.83.03 in case that helps.

 

After updating to 1.83.03, this got rid of my audio errors in videos without sound but only after performing the fix that Frank  Papenmeier details here: https://groups.google.com/forum/m/#!msg/psychopy-users/UAvwnU4apx4/qBnzTNfYCgAJ i.e. removing the single argument in GL.glPopAttrib(GL.GL_ENABLE_BIT) function detailed on line 356 of movie3.py.

 

Cheers

 

Kris

Kris McCarty

unread,
Jan 14, 2016, 2:57:23 PM1/14/16
to psychopy-users
Update on this, 

I found that encoding the videos as wmv and using wma8 audio encoding solved the issues with all videos and everything runs very smoothly.

I'd still be very interested in knowing more about those errors with .avi and.mp4 as ill be dealing with video a lot in the future.

Cheers

Kris

On Tuesday, 12 January 2016 10:27:58 UTC, Jon wrote:

Guillaume Berna

unread,
Feb 26, 2016, 6:10:00 AM2/26/16
to psychopy-users

Having encountered the same problem, I think i've found the explanation: The soundtrack has a shorter duration than the video, which explain the 'index is out of bounds'.

The solution is either to remove the sound track (in the file or psychopy options), or to re-encode.

Cheers,

Guillaume

pyo version 0.6.6 (uses single precision)

Traceback (most recent call last):

 
File "C:\Users\xxx\test_video_lastrun.py", line 321, in <module>
    depth
=0.0,
 
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.83.04-py2.7.egg\psychopy\visual\movie3.py", line 121, in __init__
   
self.loadMovie(self.filename)
 
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.83.04-py2.7.egg\psychopy\visual\movie3.py", line 168, in loadMovie
   
self._audioStream = sound.Sound(self._mov.audio.to_soundarray(),

 
File "<string>", line 2, in to_soundarray
 
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\decorators.py", line 54, in requires_duration
   
return f(clip, *a, **k)
 
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\audio\AudioClip.py", line 114, in to_soundarray
    chunksize
=buffersize))
 
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\numpy\core\shape_base.py", line 230, in vstack
   
return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
 
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\audio\AudioClip.py", line 81, in generator
    buffersize
=chunksize)
 
File "<string>", line 2, in to_soundarray
 
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\decorators.py", line 54, in requires_duration
   
return f(clip, *a, **k)
 
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\audio\AudioClip.py", line 127, in to_soundarray
    snd_array
= self.get_frame(tt)
 
File "<string>", line 2, in get_frame
 
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\decorators.py", line 89, in wrapper
   
return f(*new_a, **new_kw)
 
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\Clip.py", line 95, in get_frame
   
return self.make_frame(t)
 
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\audio\io\AudioFileClip.py", line 71, in <lambda>
   
self.make_frame =  lambda t: reader.get_frame(t)
 
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy-0.2.2.11-py2.7.egg\moviepy\audio\io\readers.py", line 196, in get_frame
   
"but len(buffer)=%d\n"%(len(self.buffer))+ str(error))
IOError: Error in file 3003.avi, At time t=40.82-41.64 seconds, indices wanted: 100000-136323, but len(buffer)=136305
index
136305 is out of bounds for axis 0 with size 136305


Reply all
Reply to author
Forward
0 new messages