Control Hyperdeck via ATEM with PowerShell script

SwitcherLib now supports Blackmagic Hyperdeck control (version 2.9).

Everything but media file details has been implemented.

Full list of features:
hyperdeckfeatures

Example PowerShell:

add-type -path ‘C:\Users\ian\Documents\WindowsPowerShell\SwitcherLib.dll
$Global:atem = New-Object SwitcherLib.Switcher(“192.168.0.240”)
$atem.Connect()
$HyperDeck=$atem.GetHyperdecks()
$HyperDeck.Capacity
$HyperDeck[0].NetworkAddress
$HyperDeck[0].RemoteAccessEnabled
$HyperDeck[0].Play()
start-sleep 5
$HyperDeck[0].stop()
$HyperDeck[0].CurrentClipTime
Start-Sleep 5
$HyperDeck[0].CurrentClipTime = “00:02:00:25”
start-sleep 5
$HyperDeck[0].Jog(500) #jump 5 seconds (50p)
start-sleep 5
$HyperDeck[0].CurrentClip=1
$HyperDeck[0].Play()
start-sleep 5
$HyperDeck[0].stop()
$HyperDeck[0].CurrentClipTime
$HyperDeck[0].CurrentTimelineTime #time from start of clip 0

 

Advertisements

Controll Blackmagic Hyperdeck from PowerShell

Having just acquired a HyperDeck, I wanted a bit more flexibility in controlling it than the from panel buttons provided. The ability to control the Hyperdeck via an Ethernet connection is very simple and well documented in the product manual so I set about building a simple PowerShell script to do the job. Source is here https://gist.github.com/imorrish/50b96d5e6ef565b22f0a#file-gistfile1-txt The script can take command line arguments to execute a number of sequential command to the HyperDeck or run in interactive mode, taking keyboard input to perform actions. Below is a screen shot showing details about the device and clips. HyperDeck POSH
Code:

<pre>## HyperDeckTest.ps1
## By Ian Morrish
## Control Blackmagic HyperDesk via Ethernet from Windows PowerShell. PowerShell is part of all modern Windows desktop/server products
## see https://technet.microsoft.com/en-us/scriptcenter/powershell.aspx
##
## To run the script requires enabling PowerShell Script file execution. Run the following command to allow only local scripts to be executed
##    set-executionpolicy remotesigned
#
#run with command line e.g.
#   PS > .\HyperDeckTest.ps1 -remoteHost "10.0.0.34" -commands @('remote: override: true', 'goto: clip id: 2','play: single clip: true')
#Or with no commands to get interactive menu mode 
#
#default parameters below are used if you don't provide any (update HyperDeck IP address if you want to run in interactive mode)
param( [string] $HyperDeckIP = "10.0.0.34", [string[]] $commands = @('remote: override: true'))
$port = 9993
$TempLogFilePath = "c:\temp\HyperDeck.log"
function WriteCommand($strCommand){

		## Write single command to the HyperDeck
        write-host $strCommand
		$writer.WriteLine($strCommand) 
        $writer.Flush()
        Start-Sleep -m 500
        while($stream.DataAvailable) {
			$read = $stream.Read($buffer, 0, 1024)
			write-host -n ($encoding.GetString($buffer, 0, $read))
		}
}

Start-Transcript -Path "$TempLogFilePath"


	write-host "Connecting to $HyperDeckIP on port $port"
	$socket = new-object System.Net.Sockets.TcpClient($HyperDeckIP, $port)

	if($socket -eq $null) {
		write-host "Failed to connect to $HyperDeckIP on port $port"
		Exit
	    }

	$stream = $socket.GetStream() 
    $writer = new-object System.IO.StreamWriter($stream)

	$buffer = new-object System.Byte[] 1024
	$encoding = new-object System.Text.AsciiEncoding

	#Loop through $commands and execute one at a time.

	for($i=0; $i -lt $commands.Count; $i++) { ## Allow data to buffer for a bit start-sleep -m 500

		## Read all the data available from the stream, writing it to the ## screen when done.
		while($stream.DataAvailable) {
			$read = $stream.Read($buffer, 0, 1024)
			write-host -n ($encoding.GetString($buffer, 0, $read))
		}

		write-host $commands[$i]
		## Write the command to the remote host
		$writer.WriteLine($commands[$i]) 
        $writer.Flush()
        Start-Sleep -m 500
	}


if ($commands.Count -eq 1){
    ## run in interactive mode
do {$strResponse = Read-Host "Shorcuts = ? - help, di - device Info, ci - clip info, p - play, s - stop, 1-10 clip, Q when you want to quit application?"

    switch ($strResponse)
    {
            "?" {WriteCommand('help')}
            "c" {WriteCommand('configuration')}
            "ci" {WriteCommand('clips get')}
            "di" {WriteCommand('device info')}
            "s" {WriteCommand('stop')}
            "p" {WriteCommand('play')}
            "r" {WriteCommand('record')}
            "1" {WriteCommand('goto: clip id:1')}
            "2" {WriteCommand('goto: clip id:2')}
            "3" {WriteCommand('goto: clip id:3')}
            "4" {WriteCommand('goto: clip id:4')}
            "5" {WriteCommand('goto: clip id:5')}
            "6" {WriteCommand('goto: clip id:6')}
            "7" {WriteCommand('goto: clip id:7')}
            "8" {WriteCommand('goto: clip id:8')}
            "9" {WriteCommand('goto: clip id:9')}
            "10" {WriteCommand('goto: clip id:10')}
	    default {WriteCommand($_)}

    }
    }
until ($strResponse -eq "Q") 
}
	## Close the streams
	## Cleans everything up.

    write-host "exit"
    $writer.Flush()
     #   start-sleep -m 500
    while($stream.DataAvailable) {
			$read = $stream.Read($buffer, 0, 1024)
			write-host -n ($encoding.GetString($buffer, 0, $read))
		}
	$writer.Close()
	$stream.Close()
	stop-transcript
	#The end</pre>