Make Your Own Video Conferencing Virtual Background

Created on April 22, 2020 by Richard Kelly
Tags: processing

Make Your Animation

The following Processing script creates a graphic animation, and saves the first 120 frames.

I changed the image size to 1280x720 based on Zoom’s recommendations for a widescreen camera.

Animation Thumbnail
float angle = 0.1;

void setup() {
  size(1280, 720);
  smooth();
  noStroke();
  background(0);

  frameRate(12);
}

void draw() {

  float size = map(sin(angle),-1,1,0,height);
  rectMode(CENTER);
  translate(width/2, height/2);
  rotate(angle);
  noStroke();
  fill(255,255);
  rect(0,0, size, size);
  angle += 0.0523 ;

  noStroke();
  fill( 0, 15);
  rect(0, 0, width, height);

  if(frameCount <= 120){
    TImage frame = new TImage(width,height,RGB,sketchPath("frame_"+nf(frameCount,3)+".png"));
    frame.set(0,0,get());
    frame.saveThreaded();
  }
}
class TImage extends PImage implements Runnable{//separate thread for saving images
  String filename;

  TImage(int w,int h,int format,String filename){
    this.filename = filename;
    init(w,h,format);
  }

  public void saveThreaded(){
    new Thread(this).start();
  }

  public void run(){
    this.save(filename);
  }

}

1

Other programs that can help make the animation files are:

Where Did Files Go?

In order to find where the sketch files were saved, try this command. In my case, they went to a folder in \tmp.

println(sketchPath(""));

2

Creating .mp4 File

Now we use ffmpeg to convert these .png files directly to an .mp4 which can be used by the Zoom client.

$ ffmpeg -framerate 30 \
    -i frame_%03d.png \
    -c:v libx264 \
    -r 30 \
    -pix_fmt yuv420p \
    mybackground.mp4

3

Using with Zoom Client

Play around with the settings, and have fun.

This technique should work with other web conferencing clients like GoToMeeting, WebEx, and Skype with some modifications.


  1. George Profenza. https://stackoverflow.com/a/22133355↩︎

  2. kll. https://discourse.processing.org/t/sketchpath-returns-the-wrong-sketch-path/14215/2↩︎

  3. Rinzwind. https://askubuntu.com/a/745766.↩︎