// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com

// Example 16-1: Display video

// Step 1. Import the video library
import processing.video.*;

// Step 2. Declare a Capture object
Capture video;

void setup() {
  // Step 3. Initialize Capture object via Constructor
  // video is 320 x 240, @15 fps
  video = new Capture(this,320,240,15);

void draw() {
  // Check to see if a new frame is available
  if (video.available()) {
    // If so, Step 4. Read the image from the camera.
 // Step 5. Display the video image.
  • Stefan.

    Need help VDIG…………………….. is there any way to run this,
    it is asking for VDIG……..

  • http://www.learningprocessing.com Daniel Shiffman

    If you are on windows you will need a vdig. You can download one here:


  • Leslie Solorzano

    I am having a “little” problem it throws a java.lang.NoClassDefFoundError I am working on linux and I have all things related to quicktime installed, si there a way I can change this or tell processing where to find it?

  • Koral

    Hi Daniel, Iwould like to know if you can help me, I would like to do a proyect where processing will draw the motion of people walking arround. I don’t know exactlly how can I do it, could you help me please :) thanks

  • bob toms

    why is this not working, it shows a black screen? I am using new macbook pro, any help would be greatly appreciated!

  • shiffman

    I am working on updating these examples for Processing 2.0. You need to add video.start() if you are using 2.0.

  • Bruno S

    Hi, im begining to experiment with artificial vision aplications and I thought Processing would be a good tool, but I got a silly question I hope you can help me. When I use the camara integrated in my Laptop the video seems fine, but when I change the size, lets say 640×480, the video become all fuzzy and wierd, my face appear like 4 times on the screen. But when I use an USB webcam this problem doesnt happen. You know why this happen? I hope you can help me, Thanks.

  • sebas

    Where? I am workin in a pc…

  • shiffman
  • sebas

    thank you! now it works!

  • aschenbrennerin

    Hey, I’m having a problem with high resolution camera pictures, they aren’t displayed and I get the following error message after a while. Can somebody help me?

    (javaw.exe:6520): GStreamer-CRITICAL **:
    Trying to dispose element rgb, but it is in READY instead of the NULL state.
    You need to explicitly set elements to the NULL state before
    dropping the final reference, to allow them to clean up.
    This problem may also be caused by a refcounting bug in the
    application or some element.

  • shiffman
  • Ceren

    Hi Daniel,
    How can I use this sketch with an external usb camera on mac? When I create a string with the camera name, Processing 2.0 gives me a NullPointerException for video.start()

    Many thanks.

  • aschenbrennerin
  • aschenbrennerin
  • emin deniz

    Hi i run your codes and there were just a black screen before that i run another codes like that;

    void setup(){

    cam=new Capture(this,320 ,240, 30);


    void draw() {


    As i know it is the basic codes of open webcam in processing why dou you think i can not open it ? please help me.
    p.s. : i use windows 7 64bit

  • Adrian Stein

    hey im also getting just a black screen….

  • shiffman

    see the new examples, the API has changed, apologies for this site being so out of date: https://github.com/shiffman/LearningProcessing/tree/master/chp16_video

  • Adrian Stein


  • bob

    How would you tell processing wich camera to use, because I don’t wanted to use the one integrated in my computer, I want to use a portable web cam for an arduino project

  • shiffman

    use capture.list() to see what is available and then select the one you want in the constructor. See https://processing.org/reference/libraries/video/Capture.html for more specifics.

  • Ben Kt

    Hi Daniel, I have a problem getting a webcam image in processing. Kindly ask for your advice.

    My webcam supports a list of outputs, amongst them: 1920×1080@5, 1920×1080@30 and 1280×720@60.

    If I use your sketch base with 1920×1080@5fps, everything works fine. But, if I try to use 1920×1080@30 or 1280×720@60, the stage stays black.

    If I lower the resolution beneath HD, it works fine as well. Any advice on this? Is Processing not able to handle big-resolution, high-fps webcams?

    Thank you,

  • shiffman

    What shows up when you print Capture.list()? I would try asking this at forum.processing.org as users who have tried lots of different cameras might have good advice.