Program stops running at some point

I have a program that searches for all the frames in a 864.000 frame video to spot the different ones and save them for me. But for some reason, the program stops running at around 10% of the progress. The video is the following(I downloaded it): https://www.youtube.com/watch?v=7ly6hgzwsLU&t=30606s

My code is the following:

import processing.video.*;

Movie video;

void setup() {
  video = new Movie(this, "24h.mp4");
  System.out.println("Video loaded!");
  
  System.out.println("Analysing frames...");
  
  video.play();
  for (int i = 0; i < 864000; i++) {
    video.jump(i);
    if (video.available()) {
      video.read();
      PImage p = createImage(16, 9, RGB);
      p.copy(video,  0,0, video.width,video.height,  0,0, video.width,video.height);
      if (!check(p)) p.save("frame" + i + ".jpg");
      if (i != 0 && i%864 == 0) System.out.println((float)i/8640 + "% complete...");
    }
  }
  System.out.println("Done!");
}

void draw() {}

boolean check(PImage a) {
  a.loadPixels();
  for (int i = 0; i < a.pixels.length; i++) {
    if (brightness(a.pixels[i]) > 2) return false;
  }
  return true;
}

Why does it stop running?

When you say it “stops running” do you mean it crashes? Is there an error message? Does it freeze?

1 Like

It just freezes at the frame 86399 (9,99%), and just stops there

Does it work if you stop short of the last frame?

for (int i = 863990; i < 863999; i++) {

Or does it also hang on that new last frame?

Hey, sorry for the long time to answer, school is busy these weeks. It just runs frame 863990 and says it’s finished without analysing the other 9 frames. Changing the number to 863999 didn’t change anything. Starting on 863900 also makes it look only the first frame. I changed the limit to 10 times it (8640000) to see if it worked too, but nothing changed. It still stopped on 86399.

Oops, my fault, I meant to write

for (int i = 86390; i < 86399; i++) {

That is, just process the frames before the frame that freezes. Perhaps that one frame is damaged somehow? Or perhaps the frame count isn’t correct, and there are no frames beyond that point.