2

画面記録を開始しようとすると、数秒待ってから記録を停止し、保存された記録をディスクにエクスポートします。

バージョン

  • アップルスクリプト 2.2.4
  • クイックタイム: 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

stop コマンドと start コマンドは正しく機能しますが、exportコマンドは次のエラーで失敗します。

movie_record.scpt:215:294: execution error: QuickTime Player got an error: Can’t get document "Movie Recording". (-1728)
4

2 に答える 2

4

停止コマンドが発行された後、ドキュメントの名前が変更されることに注意してください...

set filePath to (path to desktop as text) & "movie.mov"

tell application "QuickTime Player"
    set newMovieRecording to new movie recording
    set windowID to id of first window whose name = "Movie Recording"

    tell newMovieRecording
        start
        delay 2 --(seconds)
        stop
    end tell

    set newMovieRecordingDoc to first document whose name = (get name of first window whose id = windowID)
    tell newMovieRecordingDoc to export in filePath using settings preset "iPod"
    --tell newMovieRecordingDoc to export in filePath using settings preset "25 fps"
end tell
于 2013-06-26T20:35:48.240 に答える
2

解決策を見つけました。スクリプトが呼び出されてから実際に記録が開始されるまで、わずかな遅延 (約 2 秒) があることに注意してください。

(*********************************************
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.mov' 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
于 2013-07-11T18:14:09.110 に答える