Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use iMovie like a VCR with UI scripting Apps
I have my cable TV running through an old VCR, which is connected to my Mac using my mini DV camera as a bridge. I wanted to record some of my favorite shows onto DVD without commercials. After trying GCam and QuickTime Broadcaster, I decided I preferred the quality I got using iMovie the best. On the plus side, it's a breeze to cut out commercials, make chapters and create an iDVD project.

But some of the shows I want only air late at night when I prefer to be asleep. Since iMovie isn't AppleScriptable, I gave UIElementInspector a whirl. As it turns out, some of iMovie's elements have names and parents with names, but many do not. After trial and error, I came up with the following two AppleScripts. I schedule them to run at appropriate times using iKey, but I'm sure cron and osascript would work just as well, along with any number of other "timed" launchers.

As I am not an adept AppleScripter, I have to make sure that iMovie is already open with a "fresh" project file ready and waiting. Start Importing.scpt
tell application "iMovie"
  activate
end tell

-- Start recording
tell application "System Events"
  tell process "iMovie"
    tell window 1
      tell group 3
        -- Make sure we start in edit mode
        -- so that the following toggle button
        -- works as desired
        click button 3
        -- Now switch to camera mode
        click button 2
      end tell
      tell group 1
        click button "Import"
      end tell
    end tell
  end tell
end tell
Stop Importing.scpt
tell application "iMovie"
  activate
end tell

-- Stop recording
tell application "System Events"
  tell process "iMovie"
    tell window 1
      tell group 1
        click button "Import"
      end tell
      tell group 3
        click button 2
      end tell
    end tell
    tell menu bar 1
      tell menu bar item "File"
        tell menu "File"
          click menu item "Save Project"
        end tell
      end tell
    end tell
  end tell
end tell
This screenshot may help explain how some of the scripting works...
    •    
  • Currently 1.83 / 5
  You rated: 2 / 5 (6 votes cast)
 
[20,084 views]  

Use iMovie like a VCR with UI scripting | 13 comments | Create New Account
Click here to return to the 'Use iMovie like a VCR with UI scripting' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use iMovie like a VCR with UI scripting
Authored by: mclii on Oct 11, '04 01:39:19PM

That sounds like a very cool script!

What type of camera do you have to act as the DV bridge? I believe with the Canon ZR10 that I have, it won't work properly as a DV bridge. As soon as I plug in a firewire cable, no other inputs/outputs are recognized, as far as I can tell. In the past I've had to record what I wanted digitized to a miniDV tape, and then go from there. Is there something that you're doing differently, or is your camera hardware just able to act as a bridge?



[ Reply to This | # ]
Canon ZR80
Authored by: jecwobble on Oct 11, '04 02:43:20PM

Just like Dale said, if you have a menu option for AV -> DV, you can do it. Check your user's manual.



[ Reply to This | # ]
Use iMovie like a VCR with UI scripting
Authored by: Dale Sorel on Oct 11, '04 02:18:17PM

Go into the VCR menu and see if you have a AV->DV out setting. If so, turn it on and you can pass video through your DV camera. You will have to take the tape out for it to work right.

With my ZR40 I am then able to watch TV right in iMovie. Just click Import to save something to disk. This works great with my TiVo for archiving things to VCD/SVCD.



[ Reply to This | # ]
Update
Authored by: jecwobble on Oct 11, '04 03:08:40PM

Just a quick update. If your computer is already getting a DV stream via FireWire when iMovie launches, iMovie appears to automatically switch from edit to camera mode, so the following portion of the start script is redundant.


tell group 3
  -- Make sure we start in edit mode
  -- so that the following toggle button
  -- works as desired
  click button 3
  -- Now switch to camera mode
  click button 2
end tell

Also, I'm finding that I have to put a pause in the script to ensure that iMovie is ready for its buttons to be pushed. :-) So you might want to include something like this between the two tell blocks:


do shell script "sleep 5"

Finally, I'm finding iKey to be a bit buggy with it's timer feature, so I've resorted to using cron and osascript instead. It appears to be more trustworthy as a VCR timer.



[ Reply to This | # ]
"do shell script sleep"? why not just...
Authored by: baronworm on Oct 11, '04 03:54:07PM

"delay 5"?

but I guess I'm splitting hairs when we're talking about the most efficient way to tell a program to "please sit and do nothing..."

;-)



[ Reply to This | # ]
"do shell script sleep"? why not just...
Authored by: jimhoyt on Oct 11, '04 07:18:13PM
If you take a look at your cpu usage for the two commands you'll find that

do shell script "sleep 5"

churns up far less of your Mac than

delay 5

Try it! :)

[ Reply to This | # ]

Precisely!
Authored by: jecwobble on Oct 12, '04 01:02:28PM

I use "sleep" instead of "delay" for the very reason Jim states above. In fact, I search these hints while writing the AppleScript because I had this vague nagging feeling there was something bad about "delay".



[ Reply to This | # ]
Control with iCal
Authored by: Anonymous on Oct 12, '04 02:05:28AM

You can control the start and stop with iCal if you want.

What to do

- In the Script Editor save the start script as an Application bundle and do the same for the stop script.
- Open up iCal and make a new event change the 'from' property to the date and time you want to record.
- Change the 'alarm' property to 'Open File' then select your previously saved start script. And have it start 1 minute before event start time.
- Now you will have to make a separate event as above for the stop script.
- If you have the iCalAlarmScheduler in your Startup Items you don't even need to have iCal open for this to work.



[ Reply to This | # ]
Great suggestion
Authored by: jecwobble on Oct 12, '04 01:06:59PM

Your idea has the added benefit of being able to label each start and stop event with the program name being recorded.



[ Reply to This | # ]
Great hint.
Authored by: PsiPhi on Oct 12, '04 05:00:48PM
This type of hint is exactly why I visit this site every day. I'd had similar thoughts about doing this but never had the motivation to do the (admittedly niggling amount of) research to do it from scratch, but this hint has given me a jumping off point and a kick in the pants to get going. Thanks to jecwobble and Rob both.

Anyway, I had a thought on how to extend this - IF you have the software - namely FCP (as I do):

You could set the capture settings to something with a smaller bitrate than the uncompressed DV that iMovie uses (and, of course, FCP can do) - say, Sorenson 3 or, oh... MPEG-4 with AAC audio. ;) This would obviously GREATLY save disk space as FCP will capture compressed footage on the fly.

One caveat:

I'm not sure if FCP is "UI-Scriptable" but I suspect it probably is (heck, it may even be "Vanilla AppleScriptable" - now that I think of it. Never bothered to look). I'll be looking into this. If not, a simple post-processing script could help out...

[ Reply to This | # ]
Alas, FCP is not scriptable, AFAIK
Authored by: socoast on Oct 13, '04 06:39:57PM

The previous hints for scripting iMovie and also setting an iCal alarm to start and stop are great!
I've got an unused G4/733 with SuperDrive and lots of empty HD space, a Sony Media converter box, and DISHTV with dual tuners.
I think I see a media center in my future!
I don't mind editing the iMovie video and exporting to a smaller file size.

How about using BTV Pro as the capture app?



[ Reply to This | # ]
Using Quicktime Pro 7 Instead
Authored by: GT-DVR on Nov 12, '05 07:01:04PM

You can also use QuickTime Player (Pro Version) to do the same thing. It's a little simplier and is extremely reliable:


-- Start Quicktime Pro 7 Recorder.
-- Define Recorder Settings inside QT Pro Recorder Preferences
-- by GT-DVR 2005

tell application "QuickTime Player"
activate

do shell script "sleep " & (2)

tell application "System Events"
tell application process "QuickTime Player"
click menu item "New Movie Recording" of menu "File" of menu bar item "File" of menu bar 1
keystroke return
-- hide quicktime player while recording
click menu item "Hide QuickTime Player" of menu "QuickTime Player" of menu bar item "QuickTime Player" of menu bar 1
end tell
end tell
end tell



-- Stop Quicktime Pro 7 Recorder.
-- Define Recorder Settings inside QT Pro Recorder Preferences
-- by GT-DVR 2005

tell application "QuickTime Player"
activate
do shell script "sleep " & (2)
tell application "System Events"
tell application process "QuickTime Player"
keystroke return
do shell script "sleep " & (2)
-- hide quicktime player after recording
click menu item "Hide QuickTime Player" of menu "QuickTime Player" of menu bar item "QuickTime Player" of menu bar 1
end tell
end tell
end tell



[ Reply to This | # ]
Use iMovie like a VCR with UI scripting
Authored by: Emeraldscorpion on Dec 31, '10 02:50:58AM

Hi, I'm already recording using an iMovie applescript. I set an event using iCal, set a record script as an alarm, then set an event for the end of the show with a stop recording script. However, this is quite bothersome, hence I'm trying to make an app to do this for me by setting an event and applescript alarm for me in iCal. Is this possible?



[ Reply to This | # ]