Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Attempting to start a screen recording, wait a few seconds, stop the recording and export saved recording to disk.

Versions

  • AppleScript 2.2.4
  • QuickTime: 10.2

AppleScript

set filePath to "" & (path to desktop)

tell application "QuickTime Player"
    set newMovieRecording to new movie recording
    tell newMovieRecording
        start
        delay 2 --(seconds)
        stop
        export newMovieRecording in (filePath & "movie") using settings preset "25 fps"
    end tell
end tell

The stop and start commands work correctly but the export command is giving failing with this error:

movie_record.scpt:215:294: execution error: QuickTime Player got an error: Can’t get document "Movie Recording". (-1728)
share|improve this question
up vote 0 down vote accepted

Found a solution. Note that there is a slight delay (about ~2 seconds) from the time the script is invoked until the recording actually begins.

(*********************************************
Record a Single `QuickTime` Movie
Args:
    1. name: The name of the movie.
    2. seconds: The length of the movie you want to record in seconds.
Usage:
    > osascript movie_record.scpt 'name' 5
    > osascript movie_record.scpt <file_name> <seconds>
**********************************************)
on run argv
    set movieName to item 1 of argv
    set delaySeconds to item 2 of argv
    set filePath to (path to desktop as text) & movieName
    set f to a reference to file filePath

    tell application "QuickTime Player"
        set newMovieRecording to new movie recording

        tell newMovieRecording
            start
            delay delaySeconds
            pause
            save newMovieRecording in f
            stop
            close newMovieRecording
        end tell
    end tell
end run
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .