2015-05-01 2 views
0

Я знаю, что, вероятно, очень простой ответ на этот вопрос. Я пытаюсь настроить приложение Applescript, которое при активации запускает quicktime, открывает новую видеозапись, устанавливает камеру и звук, запускает запись, а затем завершает запись и сохраняет ее через 30 секунд.Установите камеру в quicktime с помощью applescript

В настоящее время у меня есть сценарий, который делает все, кроме настройки камеры и источника звука. Любые советы о том, как выбрать определенную камеру и источник звука с помощью 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 получил сообщение об ошибке: Невозможно сделать Blackmagic каждого записывающего устройства документа« Запись видео »в спецификатор типа». номер -1700 от Blackmagic каждого устройства видеозаписи документа «Запись видео» в спецификатор

+0

Я заинтригован этой линии: установить текущую камеру newMovieRecording к Blackmagic из устройства видеозаписи Где находится "Blackmagic"? Я попытался заменить это на строку, содержащую имя моего iPhone, и получил «Доступ не разрешен». –

ответ

0

используйте свойства current camera и current 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 
+0

Эй, я попробовал некоторые из вашего кода и получил ошибку. Я отредактировал мой оригинальный вопрос, чтобы показать мой полный скрипт с битом кода от вас, который я добавил, и ошибки. Дайте мне знать, если у вас есть идеи. Благодаря! – Nick

+0

просмотрите 'видеозаписывающие устройства' в другом скрипте и выберите из списка устройств, используя пункты 1, 2, 3 и т. Д. Я не мог понять, как напрямую указывать устройства, но это делает работу. –

+0

Итак, я пробовал код точно так же, как у вас есть, и я до сих пор получаю сообщение об ошибке «Результат: ошибка« Невозможно получить каждое записывающее устройство с отсутствующим значением ». Число -1728 из каждого« класса vdev »отсутствующего значения». – Nick

0

Я совершил это, делая это вручную

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

Смежные вопросы