Record Automatically with iSight at Login
So while we’re on the subject of this engagement, I thought I would elaborate a bit on how exactly I got the automatic video recording to work.
By way of a miracle, I ended up with a brand new white MacBook to give to my love. Since my proposal was impending at the time, I figured I would have to work the MacBook into the proposal. Obviously, setting a picture of the ring as a background would work, but having seen several others capture their proposals on camera, I immediately had the idea to capture it with the MacBook’s iSight!
I looked high and low for a command line program that would capture video from the iSight, but I had little luck. I did find isightcapture, but it only seems to support capturing single frames and forget about audio. VLC would capture video from the iSight and has a command line counterpart, but I couldn’t find any documentation on specifically capturing video with the iSight from the command line. Having little luck capturing video from the command line, I turned to AppleScript.
I considered trying to Automate Photobooth or iMovie to capture the video, but there were problems with both. At some point during my scouring of the Internet I found Iris. This program was relatively dated, but contained one key feature that would help me out. It had a shortcut key to automatically start recording video! ⌘+R (command + “r”) was just what I needed! Now all I needed to do was get Iris opened and send it the key combination. Enter AppleScript…
-- IrisActivateAndRecord1.scpt
tell application "Iris"
activate
tell application "System Events" to keystroke "r" using {command down}
end tell
That did it! The video starts recording. The next issue was hiding that the video was recording. The green camera “indicator” cannot be disabled (thank goodness…), but maybe I could at least have the application hidden and/or minimized so it doesn’t cover that all important picture of the ring.
-- IrisActivateAndRecord2.scpt
tell application "Iris"
activate
tell application "System Events" to keystroke "m" using {command down}
tell application "System Events" to keystroke "r" using {command down}
end tell
That would minimize the sucker, but since it takes a bit to startup we needed a few delays. First we needed to way for the program to “initialize”. I decided to hide the initialization window and then attempt to minimize the camera window before any of the video feed showed. The script would then wait a bit more and start recording. Here is the final script.
-- IrisActivateAndRecord3.scpt
tell application "Iris"
activate
tell application "Finder" to set visible of process "Iris" to false
delay 2
activate
tell application "System Events" to keystroke "m" using {command down}
delay 3
tell application "System Events" to keystroke "r" using {command down}
end tell
It will launch Iris if it is not already running (and bring it to the front if it is running). It will then immediately hide the application (i.e. hiding the initialization screen). After waiting 2 seconds, it will then bring Iris to focus again and minimize the application window. The script will then wait an additional 3 seconds for the camera to fully begin capturing video. Finally, the script will send the key combination to begin video recording. It works! But there’s more…
All this is great, but I have to get this thing to automatically start up with the computer. In hindsight, I could have just created an application out of the AppleScript and set it as a login item, but for whatever reason I didn’t think of this at the time. I decided to take the route of a launchd item and a BASH script. The script is dead simple.
#!/bin/bash
# Iris.sh
sleep 2
osascript ~/Desktop/IrisActivateAndRecord.scpt
The script sleeps for 2 seconds and then executes our wonderful AppleScript. The launchd file ended up being pretty darn simple as well.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/
PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>Label</key>
<string>com.iamvery.inlove.Iris</string>
<key>Program</key>
<string>/Users/hayesj/Desktop/iris.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
And there it is. The solution was pretty crude. If I really wanted to, I could have taken the time to research and develop a command line program that captures video directly from the iSight. This was a one time use deal for me, and as I see it, it worked well
.
About this entry
You’re currently reading “Record Automatically with iSight at Login,” an entry on Iamvery interesting?
- Published:
- 7.30.09 / 1pm
- Category:
- Apple, Programming
- Tags:
- applescript, bash, isight, login, mac osx, record at login, record automatically, video




Comments are closed
Comments are currently closed on this entry.