Resizing video and exporting the new size

edited January 2014 in How To...

Hi all,

I have a video that is 1920x1080 that I brought into Processing, which I then modified. When I saveFrame####.tga, there is a pretty big lag and my export is not an accurate output of the original video.

I thought if I made the video smaller, this would solve my issue. However, I am having trouble doing this.

I can resize the video by doing something like this:

image(img,0,0,smallerWidth,smallerHeight);

But when I try to loop through the pixel data, it is still grabbing the original video size.

for (int x = 0; x < img.width; x++) {
      for (int y = 0; y < img.height; y++) {
           int loc = x+y*img.width;
      }
}

What can I do?

Tagged:

Answers

  • edited January 2014 Answer ✓

    Hi,

    with image(img, 0, 0, smallerWidth, smallerHeight); you are simply placing your original image in the windows with a new size. This doesn't affect the original image.

    To achieve something like that you could use PGraphics:

        PGraphics smaller = createGraphics(smallerWidth, smallerHeight, JAVA2D);
        smaller.beginDraw();
        smaller.image(bigImage, 0, 0, smallerWidth, smallerHeight);
        smaller.endDraw();
        smaller.save("folderName/imageName"+nf(incremental, 4)+".tga");
    
Sign In or Register to comment.