Change camera in QuickTime Player using AppleScript

Hi,

I’m running 10.11.4 and trying to capture the Apple TV device which is connected to my mac using QuickTime Player.
With AppleScript I can get to the point where I’m clicking the little arrow button on the new movie recording window control panel and see the menu with available cameras and microphones.Also I can keystroke the down arrow and enter key on this menu…BUT I cannot know an index of the Apple TV item in order to choose it.
I had an idea to use video recording devices list, which gives me these devices in order of their appearance and i need a help to find an index of item whose name contains the string “Apple TV”.

Here is the script I tried:


set appleTV to "Apple TV"

tell application "QuickTime Player"
	set newMovieRecording to new movie recording
	
	set videoDevices to video recording devices
	log videoDevices
	
	repeat with device in videoDevices
		set str to name of device
		
		if str contains appleTV then
			log "found"
		end if
	end repeat
	
end tell

When I run the script the word name is selected
and
I get following error:
error “QuickTime Player got an error: Can’t make screen compression preset "Apple TV" into type specifier.” number -1700 from screen compression preset “Apple TV” to specifier

Please help!

Thank you very much

Model: Mac Mini 2011
AppleScript: 2.5
Browser: Safari 9.1 (11601.5.17.1)
Operating System: Mac OS X (10.10)