Advertisement
xeromino

pseudoGlitch

Mar 30th, 2017
513
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import processing.video.*;
  2. import com.hamoid.*;
  3.  
  4. VideoExport videoExport;
  5.  
  6. Movie movie;
  7. float n=0;
  8.  
  9. void setup() {  
  10.   size(1280, 720);
  11.   smooth(8);
  12.   background(0);
  13.   movie = new Movie(this, "beyonce.mp4");
  14.   movie.play();
  15.   videoExport = new VideoExport(this, "internetVideo" + random(9999) + ".mp4");
  16.   //videoExport.setFrameRate(30);
  17.   videoExport.startMovie();
  18. }
  19.  
  20. void draw() {
  21.   if (movie.available()) {  
  22.     movie.read();
  23.     image(makeTooBrightColorTransparent(movie, 120), 0, 0);
  24.     videoExport.saveFrame();
  25.   }
  26. }
  27.  
  28. // forum.Processing.org/two/discussion/21653/how-to-make-a-pixel-transparent
  29. // GoToLoop (2017-Mar-28)
  30.  
  31. PImage makeTooBrightColorTransparent( PImage img, int bright) {
  32.   img.loadPixels();
  33.   color colors[] = img.pixels, len = colors.length;
  34.   for (int i = 0; i < len; ++i) {
  35.     color c = colors[i];
  36.     if (brightness(c) > bright) {
  37.       colors[i] = c & ~PImage.ALPHA_MASK;
  38.     }
  39.   }
  40.   img.updatePixels();
  41.   return img;
  42. }
  43.  
  44. void mouseReleased() {
  45.   save(random(9999)+".png");
  46. }
  47.  
  48. void keyPressed() {
  49.   if (key == 'q') {
  50.     videoExport.endMovie();
  51.     //exit();
  52.   }
  53. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement