Playing video using libvlc (VLC player)

964 views
Skip to first unread message

Ron I

unread,
Apr 24, 2014, 3:07:15 AM4/24/14
to psychop...@googlegroups.com
Hi,


I am having some trouble with one issue regarding video playback in PsychoPy - when i play a video (mp4 or mov, using the H264 encoding as recommended) it doesn't play smoothly, i.e., it sometimes skips a few frames. Playing videos in other software (VLC, DIVX player, windows media player, etc.) works fine.

Not sure if it matters, but the OS is win7, and i'm running PsychoPy v1.80.03. 

I'm trying to implement the solution i saw in this thread, but to no avail. 

I tried looking at the documentation of the visual.window class to see how i can get the handle of the window used to display the video so that i use it to playback video with libvlc, but i couldn't find it.

Has anyone successfully implemented the above solution and could give me a few pointers?


Thanks !

Jonathan Peirce

unread,
Apr 24, 2014, 3:32:22 AM4/24/14
to psychop...@googlegroups.com
Sol has been developing an alternative solution using a library called OpenCV that is pretty much done in the development repository. It's faster in rendering and might mean we can get rid of avbin (Dear God, let it be true). I need to get it packaging properly in the Standalone distribution, which sounds trivial but isn't, but then we're pretty much set. :-)

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/373f0ee9-48f3-4c78-a5bc-6ce7b519895f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk/

Ron I

unread,
Apr 30, 2014, 5:46:58 AM4/30/14
to psychop...@googlegroups.com
I've managed to use PyQt to open a vlc window using libvlc.

I can get the video to play when i'm using the class that i wrote to wrap the vlc video player (i can hear the audio playback), but i'm unable to display the video on top of the PsychoPy window.

Is there something that i can change in the PsychoPy code (the experiment's code) so that it will enable me to view the Qt window which plays the video, i.e., place it in front of the PsychoPy main window, or inside it?

Thanks !

Jonathan Peirce

unread,
May 2, 2014, 6:10:45 AM5/2/14
to psychop...@googlegroups.com
If you use psychopy in windowed mode (fullscr=False) then you could create a QT window second and it may appear in front? You can't combine the QT window, nor the VLC output with an opengl context (as far as I'm aware) which is why I gave up hope that VLC was ultimately useful for our video rendering and we're focussing on the opencv solution

Jon

Sol Simpson

unread,
May 3, 2014, 8:21:46 AM5/3/14
to psychop...@googlegroups.com
If you can use the latest psychopy source from github, and can (or have ) installed opencv with the python cv2 binding,  you should try using the new MovieStim2 class. There is a demo in demos/coder/stimuli/movie2stim.py.  It seems to be able to outperform MovieStim and play even HD videos smoothly. It uses pyvlc for audio and opencv for video rendering.

The current code works well for standard video playback without looping. I will be submitting an update this weekend that has full seek and pause support as well, and ensures the video keeps up with the audio if you are using a very slow computer.

Note that Jon's solution should work, but you will not be able to get events from psychopy (using getKeys() for example) when the Qt window has focus. You will either have to use Qt's event system or psychopy.iohub.

All around, using MovieStim2 is likely a much simpler solution.

Thanks.  

Ron I

unread,
May 3, 2014, 8:37:01 AM5/3/14
to psychop...@googlegroups.com
Thank you very much ! :-)

Ron I

unread,
May 7, 2014, 5:02:41 AM5/7/14
to psychop...@googlegroups.com
First of all, thank you very much !

I got the latest version from github, and got it to run after dealing with some dependency issues, but for some reason the icons in the builder's side menu aren't responding to mouse clicks. There must be something i missed.

I'd hate to trouble you with helping me with the above, since it might be something i did wrong in the process of building the standalone windows installer.

Is there an estimate as to when the next PsychoPy standalone package (which includes MovieStim2) will be released? 

And again, thanks for all the help.


On Saturday, May 3, 2014 3:21:46 PM UTC+3, Sol Simpson wrote:

Jonathan Peirce

unread,
May 7, 2014, 6:59:57 AM5/7/14
to psychop...@googlegroups.com
What version of wx did you install. PsychoPy is currently written for 2.8.xx and does odd things in newer versions.

Jon

Jonathan Peirce

unread,
May 7, 2014, 7:36:31 AM5/7/14
to psychop...@googlegroups.com

On 07/05/2014 10:02, Ron I wrote:
>
> Is there an estimate as to when the next PsychoPy standalone package
> (which includes MovieStim2) will be released?
Not yet. Packaging these things into standalone is surprisingly tricky
so I can't commit to when it will happen. I've got a conference in a
week and lots of exam marking so it won't be in the next 2 weeks at least.

(If someone wants to speed up the process by helping me with my exam
marking....?) ;-)

best wishes,
Jon
Reply all
Reply to author
Forward
0 new messages