【问题标题】:Set a camera in quicktime using applescript使用 applescript 在 quicktime 中设置相机
【发布时间】:2023-03-28 16:56:01
【问题描述】:

我知道这可能有一个非常简单的答案。我正在尝试设置一个 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

这是我现在运行时遇到的错误。

error "QuickTime Player 出现错误:无法将文档 \"Movie Recording\" 的每个视频录制设备的 Blackmagic 转换为类型说明符。"从文件“Movie Recording”的每个视频录制设备的Blackmagic到指定者的编号-1700

【问题讨论】:

  • 我对这行很感兴趣:将 newMovieRecording 的当前摄像机设置为视频录制设备的 Blackmagic 'Blackmagic' 的定义在哪里?我尝试用包含我的 iPhone 名称的字符串替换它,并得到“不允许访问”。

标签: macos camera applescript quicktime recording


【解决方案1】:

使用您的电影录制对象的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

【讨论】:

  • 嘿,所以我尝试了您的一些代码并得到了错误。我已经编辑了我的原始问题,以显示我的完整脚本,其中包含我添加的一些代码和错误。如果您有任何想法,请告诉我。谢谢!
  • 在另一个脚本中查看 video recording devices 并使用第 1 项、第 2 项、第 3 项等从设备列表中进行选择。我不知道如何直接指定设备,但这做这项工作。
  • 所以我完全按照您的方式尝试了代码,但我仍然收到错误“结果:错误“无法获取每个缺少值的视频录制设备。”每个«class vdev 的编号 -1728 » 缺失值”。
  • 把它从我给你的代码中移出“tell newMovieRecording”或者去掉“of newMovieRecording”
  • 这在 ElCap 中对我不起作用:我将 newRecording 的当前摄像机设置为视频录制设备 deviceIndex,但电影只是使用我上次手动更改时留下的任何摄像机。跨度>
【解决方案2】:

我是手动完成的

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-05
    • 1970-01-01
    • 2020-09-24
    • 1970-01-01
    • 2022-08-05
    • 1970-01-01
    相关资源
    最近更新 更多