# How to present movies in PTB3?

**URL:** <https://psychtoolbox.discourse.group/t/how-to-present-movies-in-ptb3/279>\
**Category:** Uncategorized\
**Created:** [February 19, 2014, 7:59am UTC](https://psychtoolbox.discourse.group/t/how-to-present-movies-in-ptb3/279 "2014-02-19T07:59:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [February 19, 2014, 7:59am UTC](https://psychtoolbox.discourse.group/t/how-to-present-movies-in-ptb3/279/1 "2014-02-19T07:59:26Z")

</div>

Hello,
  

I am trying to present a 1 second movie-clip (.avi format). I am using a loop to present the movie according to the PTB best practice.

BUT - the movie presentation takes 1.5 seconds (even though the length of the clip is 1 second exactly).

Any ideas why this happens and how can I present the clip for 1 second exactly?

  

This is the part of my code displaying the movie:

  

  

movie = Screen('OpenMovie', window, fileName); 

 Screen('PlayMovie', movie, 1); 

 while 1 

 tex = Screen('GetMovieImage', window, movie);

 if tex\<=0

 break;

 end; 

 Screen('DrawTexture', window, tex);

 Screen('Flip', window);

 Screen('Close', tex);

 end;

 Screen('PlayMovie', movie, 0);

 Screen('CloseMovie', movie);

  

Thank you!

---

<div class="post-metadata">

**Author:** ![peter.scarfe](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@peter.scarfe](https://psychtoolbox.discourse.group/u/peter.scarfe)\
**Post date:** [February 19, 2014, 4:30pm UTC](https://psychtoolbox.discourse.group/t/how-to-present-movies-in-ptb3/279/2 "2014-02-19T16:30:34Z")

</div>

Heres a few things which may or may not help.
  

When you say you are using "best practice" I'm not sure what you mean. You seem to be using a similar strategy to that shown in SimpleMovieDemo. In this demo it it states:
  

% This bare-bones demo plays a single movie whose name has to be provided -

% including the full filesystem path to the movie - exactly once, then

% exits. This is the most minimalistic way of doing it. For a more complex

% demo see PlayMoviesDemo. The remaining demos show more advanced concepts

% like proper timing etc.

  

So it sounds like you are using a very basic strategy, which might not have good timing. So, I'm not sure if this is best practice.

  

You might want to have a look at the other movie demos in PTB. Which show more advanced / different ways to do movie playback. This might help with timing.

  

One thing I notice is you are not specifying a time at which you want your texture flipped to the screen. This really is not best practice. You really should specify a time you want the flip to occur to get good timing, else you are leaving a lot to chance. Numerous PTB demos show how to do this.

  

Anyhow, there are a few things you can try. Report back if you are still having issues. I rarely use movie playback. Others might have a better knowledge.&nbsp;

  

P
