# Mirror and reflect left side movie to the right side

**URL:** <https://discourse.processing.org/t/mirror-and-reflect-left-side-movie-to-the-right-side/42788>\
**Category:** Libraries\
**Created:** [September 19, 2023, 12:57pm UTC](https://discourse.processing.org/t/mirror-and-reflect-left-side-movie-to-the-right-side/42788 "2023-09-19T12:57:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatma90](https://avatars.discourse-cdn.com/v4/letter/f/df788c/32.png) [@fatma90](https://discourse.processing.org/u/fatma90)\
**Post date:** [September 19, 2023, 12:57pm UTC](https://discourse.processing.org/t/mirror-and-reflect-left-side-movie-to-the-right-side/42788/1 "2023-09-19T12:57:23Z")

</div>

Hi, I have to reflect and mirror the half of the left video with the right one. I tried this code but when I activate the effect the video shows only the first frame and does not play. How can I play the video with the effect? thanks!

 ![ex](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/3/8/3803f40636e6eac9a5d871be7a959407c7083ba5.png)

```auto
import processing.video.*;
boolean flipVideo = false;
Movie movie;

PGraphics flippedBuffer; // PGraphics buffer for the flipped video
PImage leftHalf;

void setup() {
  size(640, 480);
  frameRate(30);
  
  movie = new Movie(this, "movie.mov");
 
  movie.loop();
  movie.read();
 

  flippedBuffer = createGraphics(movie.width, movie.height); // Initialize the buffer
}

void draw() {
  if (movie.available() && overlay.available()) {
    movie.read(); 
  }

  movie.loadPixels();
  

  // Create the flipped video and store it in the PGraphics buffer
 if (flipVideo) {
   flippedBuffer.beginDraw();

 leftHalf = get(0, 0, width/2, height);
  flippedBuffer.translate(width, 0);
  flippedBuffer.scale(-1, 1);
  flippedBuffer.image(leftHalf, 0, 0);
  
  flippedBuffer.endDraw();
  } else {
    flippedBuffer.beginDraw();
    flippedBuffer.image(movie, 0, 0); // Use the original video
    flippedBuffer.endDraw();
  }
}

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

void addTuioObject(TuioObject tobj) {
...
}

void removeTuioObject(TuioObject tobj) {
 ...
}

```

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [September 19, 2023, 1:37pm UTC](https://discourse.processing.org/t/mirror-and-reflect-left-side-movie-to-the-right-side/42788/2 "2023-09-19T13:37:41Z")

</div>

Hi @fatma90,

just a quick example. PGraphics is used here to keep it independent from sketch size.  
Hope that helps …

Cheers  
— mnse

```auto
import processing.video.*;

Movie movie;
PGraphics mg;

void setup() {
  size(600, 600);
  background(0);
  movie = new Movie(this, "launch2.mp4");
  movie.loop();
  movie.read();
  mg = createGraphics(movie.width,movie.height);  
}

void draw() {
  if (movie.available()) {
    movie.read();
    PImage halfimg = movie.get(0,0,movie.width/2,movie.height);
    mg.beginDraw();
    mg.translate(mg.width/2,mg.height/2);
    mg.image(halfimg,-mg.width/2,-mg.height/2,mg.width/2,mg.height);
    mg.scale(-1,1);
    mg.image(halfimg,-mg.width/2,-mg.height/2,mg.width/2,mg.height);    
    mg.endDraw();    
  }
  image(mg, 0, 0, mg.width, mg.height);
}

```
