# Video library: grab specific frame of a movie

**URL:** <https://discourse.processing.org/t/video-library-grab-specific-frame-of-a-movie/17387>\
**Category:** Libraries\
**Created:** [January 27, 2020, 9:50pm UTC](https://discourse.processing.org/t/video-library-grab-specific-frame-of-a-movie/17387 "2020-01-27T21:50:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![keithhandy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/keithhandy/32/7947_2.png) [@keithhandy](https://discourse.processing.org/u/keithhandy)\
**Post date:** [January 27, 2020, 9:50pm UTC](https://discourse.processing.org/t/video-library-grab-specific-frame-of-a-movie/17387/1 "2020-01-27T21:50:47Z")

</div>

Hi,

I have been trying to write code to grab a specific frame from a movie file using the Movie object and the “jump” method, but I am unable to jump to a specific point in the movie unless the movie is playing. The only way I’m able to do this right now is to start playing, jump to the frame, and immediately stop playing, which gives me a few frames past the desired frame, and not a consistent number of frames. This is the hack I’ve come up with for now, but even so, it makes a set number of attempts, and doesn’t guarantee the right frame every time.

```auto
import processing.video.*;
Movie myMovie;
float desiredframe;

void setup() {
  size(800, 800);
  frameRate(30);
  myMovie = new Movie(this, "eyes.mov");
  myMovie.loop();
  myMovie.pause();
  desiredframe = 0;
}

void draw() {
  if (myMovie.available()) {
    myMovie.read();
    image(myMovie, 0, 0);
  }
}

void mousePressed() {
  if (mouseX > 2*width/3) desiredframe+=1;
  if (mouseX < width/3) desiredframe-=1;
  float desiredjump = desiredframe/30.0;
  float error = 0;
  int attempts = 0;
  while ((error <= 5.0 || error >= 6.0) && attempts < 10){
    // THIS RANGE IS TYPICAL FOR NOW BUT IF
    // IT'S NOT COMMON ENOUGH IT WILL HANG!!
    myMovie.play();
    myMovie.jump(desiredjump);      
    myMovie.pause();
    error = myMovie.time()*30 - desiredframe;
    attempts++;
  }
  println(attempts, error);
}

```

Is there a better and more reliable way to do this? I want to work on each frame of the movie, in order, without skipping or repeating frames. Thank you!

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 28, 2020, 3:34am UTC](https://discourse.processing.org/t/video-library-grab-specific-frame-of-a-movie/17387/2 "2020-01-28T03:34:50Z")

</div>

did you start from the original frame example?  
because that works here fine.  
PDE / Examples / Libraries / Video / Movie / Frames

---

<div class="post-metadata">

**Author:** ![keithhandy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/keithhandy/32/7947_2.png) [@keithhandy](https://discourse.processing.org/u/keithhandy)\
**Post date:** [January 28, 2020, 4:07am UTC](https://discourse.processing.org/t/video-library-grab-specific-frame-of-a-movie/17387/3 "2020-01-28T04:07:02Z")

</div>

I just looked at that example, and it does the same thing mine does; it plays, then jumps, then pauses. It doesn’t necessarily go to the exact frame, because of the unpredictable lag between mov.jump() and mov.pause(), even if they’re consecutive commands.
