How to stream from Open Broadcast Studio into Processing

Hi, I've been tasked with creating a photo booth for my University's Graphic Design faculty open day.

My intention is to use open broadcast studio to chroma key out a green screen and then stream that keyed video into processing where my sketch will play a branded video behind the streamed image and allow the users to take a "photo" using saveFrame(). I am using the processing video library to get available sources but OBS doesn't show up. I did try using CamTwist Studio as that shows up in the list of video sources, but the Picture in Picture doesn't work, it just flashes.

The OBS website says that it streams RTMP, I have been unable to find any libraries that specifically address this format.

This will be running on a single late 2013 Mac with a 1440p resolution (I'm unsure on the exact version specifics i'm sorry, OSX 10.something.) Though there is the possibility that it may need to display the entire keyed image + video background on up to two other Macs simultaneously.

How can I get this video stream into Processing?

Thankyou for taking the time, any help is gratefully recieved.

Main:

import processing.video.*;
Movie mov;

Capture cam;
Timer timer;
int countdownSecs = 1;

void setup()
{
  //fullScreen();
  size(1280, 720); 
  timer = new Timer(width/2, height/2);

  mov = new Movie(this, "Dimension Loop 1.mp4");
  mov.play();

  String[] cameras = Capture.list();

  if (cameras.length == 0) {
    println("There are no cameras available for capture.");
    exit();
  } else {
    println("Available cameras:");
    for (int i = 0; i < cameras.length; i++) {
      println(cameras[i]);
    }

    // The camera can be initialized directly using an 
    // element from the array returned by list():
    cam = new Capture(this, cameras[0]);
    cam.start();
  }
}

void draw()
{
  //noCursor();
  if (cam.available() == true) {
    cam.read();
  }
  image(mov, 0, 0, width, height); //displays the movie behind the webcam
  //image(cam, 0, 0, width, height); //displays the webcam top left
  pushMatrix();
  scale(-1, 1); //reverses the webcam image
  image(cam.get(), -width, 0, width, height);
  popMatrix(); 
  // The following does the same, and is faster when just drawing the image
  // without any additional resizing, transformations, or tint.
  //set(0, 0, cam);

  timer.DisplayTime();
  if (timer.theTime == countdownSecs)
  {
    capture();
  }
}

void mouseReleased()
{
  //if ((key == 's') || (key == 'S')) 
  //{
  timer.start();
  timer.currentTime();
  //}
}

void capture()
{
  timer.start();
  timer.pause();
  println("captured");
  saveFrame("Open Day Photos/CGD-PhotoBooth-2016-######.png");
}

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

Timer Class:

class Timer
{
  long startTime;    // time in msecs that timer started
  long timeSoFar;    // use to hold total time of run so far, useful in 
  // conjunction with pause
  boolean running;
  int x, y, theTime;   

  Timer(int posX, int posY)
  {
    x = posX;
    y = posY;
    running = false;
    timeSoFar = 0;
  }

  int currentTime()
  {
    if (running)
    {
      return ((int)((millis() - startTime) / 1000.0));
    } else
    {  
      return ((int)(timeSoFar / 1000.0));
    }
  }

  void start()
  {
    running = true;
    startTime = millis();
  }

  void restart()
    // reset the timer to zero and restart, identical to start
  {
    start();
  }

  void pause()
  {
    if (running)
    {
      timeSoFar =   millis() - startTime  ;
      running = false ;
    }
  }
  void DisplayTime()
  {
    String output = "";
    theTime = currentTime();
    output = output + theTime;
    fill(150, 0, 200);
    //textSize(500);
    //textAlign(CENTER);
    //text(output, x, y);
  }
}
Sign In or Register to comment.