IP Camera on Processing

Hi!

Is there a way to read an IP camera on Processing? I remember doing so years ago using a library, but I can’t find it anymore. I couldn’t find a way to do it with the regular video library.

Thanks

See if this works on your system. It works on MacOS here.

Reference: // How to fix "Internal d... | Creative Technology Lab Wiki

import processing.video.*;

Capture cam;

void setup() {
  size(640, 480);

  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, width, height, "pipeline:avfvideosrc device-index=0", 30);
    cam.start();     
  }      
}

void draw() {
  if (cam.available() == true) {
    cam.read();
  }
  image(cam, 0, 0);
  // The following does the same, and is faster when just drawing the image
  // without any additional resizing, transformations, or tint.
  //set(0, 0, cam);
}

Hello @danielcorbani,

I set up streaming with Yawcam, and this was the simplest way to simulate an IP cam (MJPEG stream) on my end.

I used this software for decades to stream content to PCs at events. It is very simple and cool and free!

You can also do this with VLC Player, OBS Studio (with plugin), and FFmpeg. I will try RTSP another day perhaps!

Note:
I did not link the Yawcam site because of pop ups on Google; this is apparently a Google thing!
I did not see them with the Brave browser.

I was able to connect with Processing and view the stream:


import processing.video.*;

Capture cam;

void setup() {
  size(640, 480);   

  String url =
    "pipeline:souphttpsrc location=http://127.0.0.1:1717/video.mjpg " +
    "! multipartdemux " +
    "! image/jpeg,framerate=30/1 " +
    "! jpegdec " 
    //+ "! videoconvert" // Worked with or without
    ;

  cam = new Capture(this, width, height, url, 30);
  cam.start();
}

void draw() {
  if (cam.available()) cam.read();
  image(cam, 0, 0);
}

References:

:)