Play video

edited May 2014 in Library Questions

Hi Folks,

Please I am trying to play a video on the code below, but I it says Could not load movie better.mp4

Please can some one help me? Code on line 21-25 and 64-74

import processing.video.*;
Movie myMovie; 
static final int DIAM = 0200, FPS = 10;
PImage bgMask;
PImage img;
PImage img2;

int x = 600;
int y = 200;
int w = 600;
int h = 250;



void setup() {
  size(1600, 1067, JAVA2D);
  frameRate(FPS);
  smooth(4);
  imageMode(CORNER);

//video Setup
  size(1600,1067);
    myMovie = new Movie(this,"better.mp4");
    myMovie.loop();
    myMovie.read();


  bgMask = loadImage("laDefense2.jpg");

}

void draw() {
  // Replace background() w/ your video feed:
  //background((color) #00FFFF);
    img = loadImage("laDefense.jpg");
    image(img, 0, 0);

  // bgMask is the foreground overlay mask:
  image(bgMask, 0, 0);
}

void mouseMoved() {
  // Alpha 0 is 100% transparent.
  // Alpha 0xFF 100% opaque:
  alphaRect(bgMask, mouseButton == LEFT? 0 : 0, DIAM);
}

void alphaRect(PImage img, color a, int dim) {
  dim >>= 1; // diameter to radius.
  a <<= 030; // move alpha channel to its right octet.


  final color[] p = img.pixels;
  final int w = img.width, h = img.height;

  final int minX = max(mouseX - dim, 0);
  final int maxX = min(mouseX + dim, w);

  final int minY = max(mouseY - dim, 0);
  final int maxY = min(mouseY + dim, h);



//If click determin region
  {
  if (mouseX > x && mouseX < x + w && mouseY > y && mouseY < y + h) {
    print("inside rect");
    img = loadImage("laDefense.jpg");
    image(img, 0, 0);
    image(myMovie, 0, 0);
  } else {
  print("outiside rect");
  }
}




  for (int row = minY; row != maxY;)
    for (int col = minX, rw = w*row++; col != maxX;) {
      final int idx = rw + col++;
      p[idx] = p[idx] & 0xFFFFFF | a;
    }

  img.updatePixels();
}
Tagged:

Answers

  • edited May 2014

    A number of remarks:

    • Choose a category when posting.
    • Don't use all uppercase in subjects. (Fixed)
    • Don't call size() twice.
    • Avoid calling loadImage() in draw() (unless you control when you do that). That's a slow operation, and it is done 60 times per second... Probably applies to alphaRect() call as well. Since the image doesn't change and there aren't so many, just load all your images in setup().

    Back to your problem: do you have any other error message? Can you read the video in a simpler sketch, like the ones given as examples in Processing? Some video formats are not supported by the video library.

Sign In or Register to comment.