Script: How to assign different video outputs if Cue image vertical or horizonal

80 views
Skip to first unread message

nelson d'aires

unread,
Mar 16, 2023, 5:59:33 AM3/16/23
to QLab
Hi,

Does anyone have a script to select video cues (with images) and assign different video outputs (Qab5) if vertical images or if horizontal images?

Thank you

micpool

unread,
Mar 16, 2023, 1:28:01 PM3/16/23
to QLab
The only way I can find to do this reliably is using  ExifTool  by Phil Harvey  which is a PERL library and cli.  It's available as a full MacOS package here (and is a very useful and comprehensive tool for getting reams of info about  image and video files)


There are other methods but Image events is flakey at best, and  mdls depends on an image having been indexed with spotlight,  There is no script method, and although #/cue/{cue_number}/cueSize# as a query in a network cue  will return a dictionary in QLab 4, it won't in QLab 5. 

You have to use OSC to set the cue video output to a stage, as that is not scriptable, so no OSC illegal characters in your surface names, or spaces.

Here's the script:
--QLab 5. Assign different video stages depending on orientation
-- check your surfaces have these names or change these names to match your surfaces (No spaces or OSC illegal characters allowed in these surface names)
set portraitStageName to "portraitSurface"
set landscapeStageName to "landscapeSurface"
set theVideoFormatsList to {"mov", "mp4"} -- add any other formats you might use to this list
set theTids to AppleScript's text item delimiters
set AppleScript's text item delimiters to "x"
tell application id "com.figure53.QLab.5" to tell front workspace
set theSelected to (selected as list)
repeat with eachcue in theSelected
if q type of eachcue is "video" then
set f to POSIX path of (file target of (eachcue) as alias)
set theDimensions to do shell script "/usr/local/bin/exiftool -T -ImageSize  '" & f & "'"

set x to first text item of theDimensions as integer
set y to second text item of theDimensions as integer
if x is greater than y then
set theStageName to landscapeStageName
else
set theStageName to portraitStageName
end if
set eachID to uniqueID of eachcue
do shell script "echo '/cue_id/" & eachID & "/surfaceName " & theStageName & "' | nc -u -w 0 127.0.0.1 53535"
end if
end repeat
end tell
set AppleScript's text item delimiters to theTids

Screen recording of demo attached

This can be adapted to automatically set  properties of video cues based on a whole host of useful parameters.


Mic
Sort stage from orientation.mov

micpool

unread,
Mar 16, 2023, 2:12:03 PM3/16/23
to QLab
Although the script above works, I have revised it to remove references to surfaces which are legacy  QLab 4 terms. All terminology and references are now QLab 5 stages

--QLab 5. Assign different video stages depending on orientation
-- check your stages have these names or change these names to match your stages (No spaces or OSC illegal characters allowed in these stage names)
set portraitStageName to "portraitStage"
set landscapeStageName to "landscapeStage"

set theTids to AppleScript's text item delimiters
set AppleScript's text item delimiters to "x"
tell application id "com.figure53.QLab.5" to tell front workspace
set theSelected to (selected as list)
repeat with eachcue in theSelected
if q type of eachcue is "video" then
set f to POSIX path of (file target of (eachcue) as alias)
set theDimensions to do shell script "/usr/local/bin/exiftool -T -ImageSize  '" & f & "'"
set x to first text item of theDimensions as integer
set y to second text item of theDimensions as integer
if x is greater than y then
set theStageName to landscapeStageName
else
set theStageName to portraitStageName
end if
set eachID to uniqueID of eachcue
do shell script "echo '/cue_id/" & eachID & "/stageName " & theStageName & "' | nc -u -w 0 127.0.0.1 53535"

end if
end repeat
end tell
set AppleScript's text item delimiters to theTids

nelson d'aires

unread,
Mar 16, 2023, 3:22:21 PM3/16/23
to QLab
Thank you so much for your work Mic, it works so good! I hope the Qlab community can also use this script, for me it will be an wonderful tool because i worl all the time with two projectores: one for portrait mode and one for landscape mode and this is a time and productivity saver! 
Once again, my sincere thanks :) 

micpool

unread,
Mar 29, 2023, 5:33:21 AM3/29/23
to QLab
In QLab 5.1.1 you no longer need to use ExifTool as you can now query  cue size width and heights which return a single number, 

/cue/X/notes #/cue/selected/cueSize/width#
/cue/Y/notes #/cue/selected/cueSize/height#

To get the results of these queries you do need actual network cues (rather than shell scripts to port 53535,) which can also store the returned dimensions in their note fields. These use /cue/selected  in the address, so the script needs to actually select the cues rather than just reference them in the repeat loop.

Screenshot 2023-03-29 at 10.25.15.png

The amended script is:



--QLab 5. Assign different video stages depending on orientation
--doesn't work in Always Audition mode!!!!
-- check your stages have these names or change these names to match your stages (No spaces or OSC illegal characters allowed in these stage names)
--requires 2 network cues numbered X and Y with OSC queries /cue/X/postWait #/cue/selected//cueSize/width#. and /cue/Y/postWait #/cue/selected//cueSize/height#


set portraitStageName to "portraitStage"
set landscapeStageName to "landscapeStage"
tell application id "com.figure53.QLab.5" to tell front workspace
set theSelected to (selected as list)
repeat with eachcue in theSelected
if q type of eachcue is "video" then
set the selected to eachcue
delay 0.01
start cue "X"
start cue "Y"
delay 0.01
set x to notes of cue "X" as integer
set y to notes of cue "Y" as integer

if x is greater than y then
set theStageName to landscapeStageName
else
set theStageName to portraitStageName
end if
set eachID to uniqueID of eachcue
do shell script "echo '/cue_id/" & eachID & "/stageName " & theStageName & "' | nc -u -w 0 127.0.0.1 53535"

end if
end repeat
end tell

Screen recording attached

MIc

Screen Recording 2023-03-29 at 10.08.23.mov

nelson d'aires

unread,
Mar 29, 2023, 10:24:54 AM3/29/23
to QLab
ah! good to know a solution without Exiftool now possible with Qlab 5.1.1.
thank you for the update ! :)

Reply all
Reply to author
Forward
0 new messages