使用AppleScript在QuickTime中设置相机



我知道这可能有一个非常简单的答案。我正在尝试设置一个applescript应用程序,该应用程序将在激活后启动QuickTime,打开新电影录制,设置相机和音频,启动录制,然后结束录制并在30秒后保存。

我目前有一个脚本,除了设置相机和音频源外,还在执行所有操作。关于如何使用AppleScript选择某个相机和音频源的任何提示?

谢谢!

这是现在的代码。

--Set some Variables
--Max length of recording
set maxrec to 20 --in seconds
--Ending Message
set EndMsg to "Thank you for participating in this project. Your video has been recorded."

--Begin Loop
repeat
--Get the person's name
repeat
    display dialog "What's your name?" default answer ""
    set theName to (text returned of result)
    if theName ≠ "" then exit repeat
end repeat
--Set the date
set theDate to current date
set y to text -4 thru -1 of ("0000" & (year of theDate))
set m to text -2 thru -1 of ("00" & ((month of theDate) as integer))
set d to text -2 thru -1 of ("00" & (day of theDate))
set h to text -2 thru -1 of ("00" & (hours of theDate))
set mm to text -2 thru -1 of ("00" & (minutes of theDate))
set dateStamp to (y & "-" & m & "-" & d & " " & h & mm as string)
--Create a folder for the person
tell application "Finder"
    set p to path to movies folder from user domain
    try
        make new folder at p with properties {name:"Video Clips"}
    end try
    set p to (path to movies folder from user domain as text) & "Video Clips:"
    make new folder at p with properties {name:dateStamp & " " & theName}
    set thePath to result
    --Establish the final name of the movie
    set fileName to ((thePath as text) & dateStamp & ".mov" as string)
end tell
--Open New Recording, start and stop it
tell application "QuickTime Player"
    set newMovieRecording to new movie recording
    set windowID to id of first window whose name = "Movie Recording"
    delay 2
    tell newMovieRecording
        --Set Camera to Blackmagic
        set current camera of newMovieRecording to Blackmagic of video recording devices
        start
    end tell
    set theSeconds to maxrec
    repeat theSeconds times
        display dialog theSeconds buttons {} giving up after 1 with title "REMAINING TIME"
        set theSeconds to (theSeconds - 1)
    end repeat
    tell newMovieRecording
        stop
    end tell
    --save and close the recording  
    set newMovieRecordingDoc to first document whose name = (get name of first window whose id = windowID)
    tell newMovieRecordingDoc to save in fileName
    set SavedRecordingDoc to first document whose name = (get name of first window whose id = windowID)
    tell SavedRecordingDoc to close
    quit
end tell
--Display "Thank You" Message
tell application "System Events" to set frontmost of process "Video Booth" to true
display dialog EndMsg giving up after 20 buttons {"Continue…"} ¬
    default button 1
end repeat

这是我运行时立即遇到的错误。

错误" QuickTime Player出现了一个错误:无法使Document " Movie Recording " Toge类型"的每个视频录制设备刻录到类型的指定器中。"来自blackmagic的数字-1700来自每个视频录制设备的文档"电影录制"到指定器

使用电影记录对象的 current cameracurrent microphone属性。只需用适当的设备替换项目1:

set current camera of recording to item 1 of video recording devices
set current microphone of recording to item 1 of audio recording devices

我通过手动进行

来完成此操作
tell application "System Events" to tell process "QuickTime Player"
    #To open dialog to show available cameras
    click button 3 of window 1
    #To select our device
    click menu item "your_camera_name" of menu 1 of button 3 of window 1
end tell

使用此对话框将打开,您将从列表中选择相机...

从我做出的另一个答案中获取:https://stackoverflow.com/a/45454785/3685973

相关内容

  • 没有找到相关文章

最新更新