O'Reilly Network    

 Published on The O'Reilly Network (http://www.oreillynet.com/)

Quartz Composer iSight Prank

by Chris Adamson
Jul. 20, 2005

I had a nightmare where someone turned on my iSight and started spying on me.

It looked a little something like this:

The above only works if you have Tiger and an iSight or other webcam. Still, it's quite a freak out moment when someone else can turn on your iSight and incorporate it into their web page, even though you're the only one seeing it.

How this trick works: Quartz Composer all the way. If you've installed the dev tools, this is definitely something to play with.

The actual composition is trivial and consists of just two pieces: the video input and a billboard to render it:


Drag a line from the video input's "Image" output to the billboard's "Image" input, then use the inspector on the billboard to set the width to 2 (you don't set the height because a billboard keeps the aspect ratio of its sources).

Export this to a QuickTime movie, 320x240. Notice how it's only 8KB - Quartz Composer compositions are a new track type for QuickTime, and they can be quite compact (especially if, like here, they don't have any media samples of their own). Open the movie in QT Player just to make sure things are hoopy. Note that only one app can use your camera at a time, so you'll have to close the Quartz Composer viewer (or quit QC) for QT Player to get the video. Happy? Embed the video in HTML (I have the boiler plate in an old QuickTime for Java article, under the heading "When Not to use QuickTime for Java"). Now you're all set to scare your dear friends.

BTW, this idea is not original to me by any means. I was originally freaked out by seeing my own image on bbum's blog-o-mat, which adds a series of video effects to the capture image (again, totally what Quartz Composer was built to do). A sample of that page:


Notice my wife's G4 Cube over my shoulder!

And I only went looking for that because of an Apple BoF at JavaOne where they showed an "A-ha Effect" video playing in a Java CocoaComponent.

Chris Adamson is an author, editor, and developer specializing in iPhone and Mac.

oreillynet.com Copyright © 2006 O'Reilly Media, Inc.