1)創建AppleScript文件,輸入一下代碼並保存。如QTRecord.scpt
tell application "QuickTime Player"
activate
start (new movie recording)
end tell
2)在終端執行
osascript QTRecord.scpt
3)或者也可以一句話搞定以上兩步
osascript -e 'tell application "QuickTime Player" to activate' -e 'tell application "QuickTime Player" to start (new movie recording)'
摘自How to start QuickTime recording at command line?
======分割線======
這幾天爲了解決錄製視頻同時記錄開始錄製的時間戳這個需求,倒騰了不少解決方案,之前也想過用命令行打開QuickTime進行錄製,但是忘了還有AppleScript,而且竟然4行就搞定了(捂臉…心痛一下我的時間)。在這裏大概記錄一下之前試過的方法。