0

Edit: I am running python 2.7.6, on Ubuntu 14.04

Edit: My ultimate goal is to output a single movie file of the output of this script

I've read all the tutorials and stackoverflow question/answers I can find on this topic and can fairly easily play a single movie, or two movies back-to-back, using pygame (using some variation of the script found here. I cannot, however, figure out how to play two at the same time. My intention is to play a movie that I have created with a different script (from this question I asked before), underneath a film clip of the same duration, and to save this product as a new video.

I understand the best way to do this would probably be to both create the movie and play it in the same script, but I am new to Python and am looking for a quick solution until I figure out the better (but more complicated) solutions. So I am just looking to play two movies that are imported into a single script, stacked one above the other.

I have been able to do this with the toolbox psychopy, but the toolbox they use to output movies (pymedia) apparently isn't in use anymore. Here is the code I used for that, which does just what I want it to, but without the ability to output the video file:

from psychopy import visual, core, event

movie01 = '/home/pbwilliams/Documents/movie01.mpg'
movie02 = '/home/pbwilliams/Documents/movie02.mp4'
win = visual.Window([800,600])
mov1 = visual.MovieStim(win, movie01, size=[320,240],pos=[0, 100])
mov2 = visual.MovieStim(win, movie02, size=[320,120],pos=[0, -100],)

globalClock = core.Clock()

while globalClock.getTime()<(mov.duration+0.5):
    mov1.draw()
    mov2.draw()
    win.update()
    win.getMovieFrame()

win.saveMovieFrames('testmovie.mpg')

core.quit()

Any help would be greatly appreciated.

Patrick

Community
  • 1
  • 1
Patrick Williams
  • 694
  • 8
  • 22
  • 2
    The code you posted is for generating a new full-screen movie, containing both of the smaller movie stimuli. What happens when you simply attempt to play both movies? You don't explain what "I cannot, however, figure out how to play two at the same time" means. The code above (minus `.getMovieFrame()` and replacing `win.update()` with `win.flip()`) *should* do what you want directly. – Michael MacAskill Nov 05 '15 at 03:14
  • Also, what version of PsychoPy are you using? The latest version (containing movie3.py) should have greatly improved ability, by using a different backend for movie playing. – Michael MacAskill Nov 05 '15 at 03:16
  • What I meant was that I cannot figure out how to play two movies simultaneously using pygame, which is one of the avenues I'm exploring to solve this problem. The psychopy solution is confounded by a need for pymedia, which itself requires the following libraries: libogg-dev, libvorbis-dev, libfaad-dev, libasound2-dev, and libmp3lame-dev. All of which I have installed, but the pymedia installer won't see them. Perhaps that could be another question. I will try your suggestions, after updating to the latest version of psychopy. Currently I am running whichever version came out last month. – Patrick Williams Nov 05 '15 at 04:38
  • Sorry for leaving out one very important detail. My goal is to save the output as a new (single) movie, not just to view the stimuli within a python created window. – Patrick Williams Nov 05 '15 at 04:46
  • Ahh, OK. Seems this is a longstanding problem: https://groups.google.com/forum/#!msg/psychopy-users/ZU6mjvr7ZYo/tugSMCPOBFMJ Can you try `win.saveMovieFrames('movie.png')` to output individual frames instead of a movie file? This is the approach needed on OS X (i.e. other software has to be used to stitch the resulting frame series into a movie). – Michael MacAskill Nov 06 '15 at 00:10
  • I ended up using Final Cut Pro. – Patrick Williams Nov 07 '15 at 17:51

0 Answers0