sleekweasel

Q: How to select a camera for Quicktime in Applescript?

ElCap 10.11.5 (15F34)

 

I'm trying to automate a screen recording of one of several iPhones we're running tests on in parallel (using several robot users on the same machine).

Since Quicktime sadly only supports one user recording at a time (even if I start a Desktop for each), I have to tell it to record the iPhone allocated to the user with the desktop, but I'm struggling with that:

 

tell application "QuickTime Player"

  repeat with i from 1 to (get video recording devices count)

  set d to (get video recording device i)

  set n to (get name of d)

# Doesn't get this far.

if item 1 of argv is equal to n then

tell recording to set current camera to d

end if

  end repeat

end tell


The error is


QuickTime Player got an error: Can’t make screen compression preset "[A][LON] 670-53 81:ie iPhone 5c 8Gb Blue" into type specifier.


....which is really annoying, dangling the very information I want right in front of me. I'm tempted to rig something involving capturing and parsing the error message, but that would be evil. I find it really hard to code in languages that hide or obscure their type information, but expect you to know what's going on.

 

'Script Debugger' says the offending AEPrint looks like this, in case it helps:


'obj '{

  'form':'name',

  'want':',

  'seld':'utxt'("[A][LON] 670-53 81:ie iPhone 5c 8Gb Blue"),

  'from':[

  0x0,

  ab0ab "QuickTime Player"

  ]

}

 

Firstly, what magical incantation should I be using for this?

 

Secondly, why isn't what seems like the obvious thing to do, working?

 

Thanks.

Posted on Jun 28, 2016 3:29 PM

Close

Q: How to select a camera for Quicktime in Applescript?

  • All replies
  • Helpful answers

  • by sleekweasel,

    sleekweasel sleekweasel Jun 28, 2016 4:16 PM in response to sleekweasel
    Level 1 (4 points)
    Mac OS X
    Jun 28, 2016 4:16 PM in response to sleekweasel

    I've made slight progress:

     

      tell application "QuickTime Player" to set n to (name of video recording device i as text)


    seems to give me the name usefully enough to check whether 'item 1 of argv' is in it, but then setting the camera to 'd' doesn't work, complaining with


    error "QuickTime Player got an error: Can’t make screen compression preset \"[A][LON] 670-53 81:ie iPhone 5c 8Gb Blue\" into type specifier." number -1700 from screen compression preset "[A][LON] 670-53 81:ie iPhone 5c 8Gb Blue" to specifier


    ...which suggests that a 'video recording device' isn't a camera, despite the documentation saying


    current camera (video recording device) : The currently previewing video device.


    and my having 'set d to (get video recording device i)'.


    Any clues welcome.

  • by sleekweasel,

    sleekweasel sleekweasel Jun 29, 2016 12:47 AM in response to sleekweasel
    Level 1 (4 points)
    Mac OS X
    Jun 29, 2016 12:47 AM in response to sleekweasel

    Seems that 'It just doesn't work': this script records with whatever camera was set last.


    I would love to hear from anyone who can explain just what is going on, or suggest an alternative.


    tell application "QuickTime Player"

    activate

    close every window saving no

      repeat with i from 1 to (get video recording devices count)

      set n to (name of video recording device i as text)

      if "[A][LON] 670-53 81:ie iPhone 5c 8Gb Blue" is in n then

      log (get video recording device i)

      set newRecording to new movie recording

      set current camera of newRecording to video recording device i

      start newRecording

      end if

      end repeat

    end tell