Created
May 3, 2019 20:27
-
-
Save imorrish/a1694d1aee22421ba1108899d2f82d73 to your computer and use it in GitHub Desktop.
Blackmagic VideoHub monitor port input rotator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param( | |
[Parameter(Mandatory=$True,Position=1)] | |
[string]$HubIP, | |
[Parameter(Mandatory=$True,Position=2)] | |
[int]$duration=120, | |
[Parameter(Mandatory=$True,Position=1)] | |
[int]$outPort, | |
[Parameter(Mandatory=$True,Position=1)] | |
[int[]]$monports | |
) | |
$port = 9990 | |
Write-host "VideoHub Monitor v2 by Ian Morrish https://ianmorrish.wordpress.com" | |
Write-host "Usage:" | |
Write-host "hubrotator.exe -hubip "192.168.1.200" -duration 120 -outport 20 -monports 1,2,5,6,9,10" | |
Function Send-TCPMessage { | |
param ( [ValidateNotNullOrEmpty()] | |
[string] $EndPoint, | |
[int] $Port, | |
$Message | |
) | |
$UTF8 = [System.Text.Encoding]::UTF8 | |
$IP = [System.Net.Dns]::GetHostAddresses($EndPoint) | |
$Address = [System.Net.IPAddress]::Parse($IP) | |
$Socket = New-Object System.Net.Sockets.TCPClient($Address,$Port) | |
$data = $UTF8.GetBytes($Message) | |
$Stream = $Socket.GetStream() | |
$Writer = New-Object System.IO.StreamWriter($Stream) | |
$Message | %{ | |
$Writer.WriteLine($_) # try new line on end "$&`r`n" | |
$Writer.Flush() | |
} | |
$Stream.Close() | |
$Socket.Close() | |
} | |
do{ | |
foreach($monport in $monports){ | |
[string]$insert = "$($outport-1) $($monport-1)" | |
$message = @("VIDEO OUTPUT ROUTING:", $insert , "`r`n") | |
Send-TCPMessage -Port $port -Endpoint $hubip -message $message | |
write-host "Viewing port - $($monport)" | |
Start-Sleep $duration | |
} | |
} | |
while($true) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment