Saturday, October 13, 2012

PEBL 0.13 New Features: Movie Playback

State Theatre in Ann Arbor, from  flickr user sfgamchic
Thanks to the new waave library, which uses the excellent ffmpeg library,  PEBL 0.13 supports simple playback of many many video and audio formats.

The video and soundfile formats supported are truly enormous
(See list of probably a hundred here)


 Although these libraries support a lot of functionality, we support a very simple (and thus simple-to-use) capability in PEBL.  Essentially, you load a video file (using LoadMovie() ) to a location on the screen (or an audio file without specifying a location on the screen using LoadAudioFile()), and then when you want to play, you use the PlayMovie() function to do so.  When it is finished, the function will complete and you can move on.


 
 There is a second method you can use too, to run a movie in the background while getting another response.  If you use StartPlayback(movie), it will start to play in the background when any Wait-type function is played.  This will, for example, let you allow the participant to watch a movie and hit a button to stop it when some particular thing takes place.  You can use PausePlayback to stop the playback from happening, and movie objects have some proporties that let you change the volume and move the playback location around.


An example experiment using the Movie functionality is shown here.  In it, the movie is played until the participant hits clicks, which pauses and unpauses the movie.  The movie is Chaplain's "The Immigrant", available in public domain from the internet archive.

The PEBL Code to do this is below:

define Start(p)
{

  ##this tests loading a simple movie, and also various audio file formats.
  gVideoWidth <- 800
  gVideoHeight <- 600

   gWin <- MakeWindow("white")
 
   movie <- LoadMovie("chaplain.mp4",gWin,640,480)
   Move(movie,50,50)

   status <- EasyLabel("Demo Movie Player",300,25,gWin,22)   
   Draw()

   StartPlayback(movie)
   Wait(1500)
   PausePlayback(movie)

  
   status.text <- "Click mouse to restart playback"
   Draw()
   WaitForDownClick()

   StartPlayback(movie)
   status.text <- "click mouse to pause playback"
   Draw()
   WaitForDownClick()
   PausePlayback(movie)

   status.text <- "Click mouse to exit"
   Draw()
   WaitForDownClick()
}





















No comments: