Capturing Video to Disk

Audio capture is nice, but if you bought this book because the sticky-note on the cover lists “capture” as one of the topics to be covered, you probably figured it meant video capture. Is there an iSight on the top of your monitor that wants some attention? OK, here’s how to turn it on and grab some video.

How do I do that?

As with audio capture, the basics of setting up capture are:

  1. Create a SequenceGrabber.

  2. Create and configure (with setUsage( ) and the settingsDialog( )) the channels you’re interested in—in this case, an SGVideoChannel.

  3. Call SequenceGrabber.setOutput( ) to indicate the file to capture to.

  4. Call SequenceGrabber.startRecord( ) to begin grabbing to disk.

  5. Finish up with SequenceGrabber.stop( ).

There is, however, a big difference with video. With no on-screen preview component available in QTJ 6.1, you must indicate where the SequenceGrabber can draw to. The workaround is to create an off-screen QDGraphics and hand it to the SequenceGrabber via the setGWorld( ) call.

The VideoCaptureToDisk program, presented in Example 6-2, offers a bare-bones video capture to a file called videograb.mov.

Note

Run this example with ant run-ch06-videocapturetodisk

Example 6-2. Recording captured video to disk

package com.oreilly.qtjnotebook.ch06; import quicktime.*; import quicktime.io.*; import quicktime.std.*; import quicktime.std.sg.*; import quicktime.std.movies.*; import quicktime.std.image.*; import quicktime.qd.*; import quicktime.sound.*; import java.awt.*; import ...

Get QuickTime for Java: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.