Access Mac Camera by Command Line

By  on  
FaceTime HD Camera

With all of my recent command line tutorials, I've really gotten excited about the shell's simplicity and realized the true power of using the underlying technology of pretty UIs.  Since I work from home, I spend a lot of time on video calls, so when I started playing around with command line utilities like ImageMagick and ffmpeg, I instantly asked myself:  how can I take a photo with the Mac's camera from within the terminal?

It turns outs out OS X doesn't provide that access; a third party utility named ImageSnap is the best route to taking captures from command line.

Install ImageSnap

I like using Homebrew to manage installs:

brew install imagesnap

You can compile from source if you like, obviously.

Take a Photo

To take a photo using the default video input device (FaceTime HD Camera is the default in most newer Macs), simply execute this:

# Take image, let camera warm up 1 second
imagesnap -w 1 snapshot.png

You'll wait a brief second or two, your green camera indicator will light up, and will then quickly fade out.  The image will be saved to a snapshot.png file.

ImageSnap also has the functionality to take a photo every n seconds:

# imagesnap -t {x}:{yy} seconds
imagesnap -t 1 -w 1

The command above takes a photo every second until the process is killed.

While I looked for this ability out of curiosity, there are some great use cases for taking images from command line, like tracking your Mac if it's stolen or taking a photo upon invalid login.  Imagesnap is an incredible utility:  simple to use and doesn't try to accomplish too much!

Recent Features

  • By
    Introducing MooTools Templated

    One major problem with creating UI components with the MooTools JavaScript framework is that there isn't a great way of allowing customization of template and ease of node creation. As of today, there are two ways of creating: new Element Madness The first way to create UI-driven...

  • By
    9 Mind-Blowing Canvas Demos

    The <canvas> element has been a revelation for the visual experts among our ranks.  Canvas provides the means for incredible and efficient animations with the added bonus of no Flash; these developers can flash their awesome JavaScript skills instead.  Here are nine unbelievable canvas demos that...

Incredible Demos

  • By
    Multiple File Upload Input

    More often than not, I find myself wanting to upload more than one file at a time.  Having to use multiple "file" INPUT elements is annoying, slow, and inefficient.  And if I hate them, I can't imagine how annoyed my users would be.  Luckily Safari, Chrome...

  • By
    Create Your Own Dijit CSS Theme with LESS CSS

    The Dojo Toolkit seems to just get better and better.  One of the new additions in Dojo 1.6 was the use of LESS CSS to create Dijit themes.  The move to using LESS is a brilliant one because it makes creating your own Dijit theme...

Discussion

  1. The utility requires a full installation of Xcode to compile this software. :P

  2. This is awesome, I didn’t know it but I’ve been looking for a utility like this for awhile now.

    Also, not to be a stick in the mud, but I’m sure you mean Facetime and not Facebook HD Camera ;)

  3. Eduardo

    I can’t install imagesnap even after installing homebrew..

  4. zalun

    I had to delay the snapshot for almost a second as photo was pure black.

    imagesnap -w 1
  5. Patricio

    is there anyway to record mac camera since terminal?

  6. JD

    Where do the images save?

  7. Crusty

    How to use Terminal to discover if any application is using my Facetime camera? With the command lsof I get all the application who request the process, but not which is using right now

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!