Movie Freezes Upon Playback

Howdy all- I’ve used Processing on and off for the past couple of years but am just now joining the forum. :slight_smile:

I’m building an occupancy detector for a museum that will pipe the current number of people in the room to a display. The display will also be looping a video clip and will likely be 1080p resolution- as is the video. The trouble is that using my current code below, the video loop will only play for around 5-10 seconds before it gets incredibly choppy if not freezes up entirely.

Here is said code. Please note that the UDP portions of code are because I wrote the object detection part of the code in Python and am just piping the occupancy data over UDP to Processing.

import hypermedia.net.*;
import processing.video.*;

UDP udp;
Movie movie;

//Scaling Parameters
int scale = 4;                                           //3 scaling options for the title bar / occupancy window: 3 for 3/8th's, 4 for 4/8th's or 5 for 5/8th's of the screen.
int textSizeTitle[] = {90, 100, 115};
int textPositionTitle[] = {6, 4, 3};
int textSizeOccupancy[] = {250, 350, 450};
int textPositionOccupancy[] = {6, 4, 3};

//Text Parameters
PFont font;

//UDP Parameters
String message = "123";

void setup() {
  font = createFont("AppleMyungjo.ttf", 128);
  
  udp = new UDP(this, 6000);
  udp.listen(true);
  
  fullScreen(2);
  
  movie = new Movie(this, "S-1 Demo - HD 1080p.mov");  
  movie.loop();
}

void movieEvent(Movie m) {
  m.read();
}

void receive(byte[] data){
  data = subset(data, 0, data.length);
  message = new String(data);
  message = message.replace(',', '\n');
  message = message.trim();
}

void displayCounterAndTitle(){
  stroke(127);
  fill(127);
  rect((width/scale) * 2, 0, width, height); 

  stroke(0);
  strokeWeight(5);
  fill(0);
  line((width/scale) * 2, height/2, width, height/2);
  line((width/scale) * 2, 0, (width/scale) * 2, height);
  
  fill(0);
  textFont(font);
  textSize(textSizeTitle[scale-3]);
  textAlign(CENTER);
  text("Current\nMammalian\nOccupancy",
    width - width/textPositionTitle[scale-3] + ((scale-3) * 15), 
    height/4 - height/9 - ((scale-3) * 10));
  textSize(textSizeOccupancy[scale-3]);
  text(message, 
    width - width/textPositionOccupancy[scale-3] + ((scale-3) * 15), 
    height/2 + height/3 + ((scale-3) * 40));
}

void draw() {
  image(movie, 0, 0);
  displayCounterAndTitle();
}

Is there a way to load the movie file into a buffer before Processing reads it? Apart from having an insufficient GPU or RAM, I’m not sure what else would be causing the freezing.

The video file I’m trying to play back is an H.264 mov file. It’s about 800MB- however I’ve also tried smaller video files and have had similar freezing issues as the larger one.

The freezing also varies depending on what computer I run it on. It’s just a 1080p video, though- it doesn’t seem like it would take a beefy computer or GPU to run.

Any suggestions or input is much appreciated! :slight_smile:

Thanks,
Amina