Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import processing.video.*;
- import com.hamoid.*;
- VideoExport videoExport;
- Movie movie;
- float n=0;
- void setup() {
- size(1280, 720);
- smooth(8);
- background(0);
- movie = new Movie(this, "beyonce.mp4");
- movie.play();
- videoExport = new VideoExport(this, "internetVideo" + random(9999) + ".mp4");
- //videoExport.setFrameRate(30);
- videoExport.startMovie();
- }
- void draw() {
- if (movie.available()) {
- movie.read();
- image(makeTooBrightColorTransparent(movie, 120), 0, 0);
- videoExport.saveFrame();
- }
- }
- // forum.Processing.org/two/discussion/21653/how-to-make-a-pixel-transparent
- // GoToLoop (2017-Mar-28)
- PImage makeTooBrightColorTransparent( PImage img, int bright) {
- img.loadPixels();
- color colors[] = img.pixels, len = colors.length;
- for (int i = 0; i < len; ++i) {
- color c = colors[i];
- if (brightness(c) > bright) {
- colors[i] = c & ~PImage.ALPHA_MASK;
- }
- }
- img.updatePixels();
- return img;
- }
- void mouseReleased() {
- save(random(9999)+".png");
- }
- void keyPressed() {
- if (key == 'q') {
- videoExport.endMovie();
- //exit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement