public/Update-CTMediaProfile.ps1
<#
https://$($ip)/stw-cgi/media.cgi?msubmenu=videoprofile&action=update EncodingType=H265 Resolution=$($resX)x$($resY) FrameRate=$($framerate) Bitrate=5120 H265.PriorityType=FrameRate H265.GOVLength=8 H265.DynamicGOVLength=8 H265.EntropyCoding=CABAC H265.Profile=Main H265.BitrateControlType=VBR H265.SmartCodecEnable=False H265.DynamicFPSEnable=False H265.MinDynamicFPS=1 Profile=1 Channel=$($channelnum) #> Function Update-CTMediaProfile { [cmdletBinding( DefaultParameterSetName='All', #SupportsShouldProcess = $true, ConfirmImpact='high' )] Param( [Parameter( Mandatory=$true, ParameterSetName='All' )] [String]$IP, [Parameter( Mandatory=$true, ParameterSetName='All' )] [pscredential]$Credential, [Parameter( Mandatory=$true, ParameterSetName='All' )] [int]$ProfileID, [Parameter( Mandatory=$true, ParameterSetName='All' )] [String]$NewName, [Parameter( Mandatory=$false, ParameterSetName='All' )] [int]$FrameRate, [Parameter( Mandatory=$false, ParameterSetName='All' )] [int]$BitRate, [Parameter( Mandatory=$true, ParameterSetName='All' )] [int]$Channel ) DynamicParam { $DynamicParameters = @{ CameraType = @{ Mandatory = $true Position = 1 ParameterSetName = "All" Enum = $Script:SupportedCameraModels } Encoding = @{ Mandatory = $true Position = 1 ParameterSetName = "All" Enum = @( 'MJPEG' 'H264' 'MPEG4' 'H265' ) } Resolution = @{ Mandatory = $false Position = 1 ParameterSetName = "All" Enum = $StandardResolutions } PriorityType = @{ Mandatory = $false Position = 1 ParameterSetName = "All" Enum = @( 'FrameRate' 'Bitrate' ) Value = 'FrameRate' } BitrateControlType = @{ Mandatory = $false Position = 1 ParameterSetName = "All" Enum = @( 'CBR' 'VBR' ) Value = 'VBR' } H26xProfile = @{ Mandatory = $false Position = 1 ParameterSetName = "All" Enum = @( 'BaseLine' 'Main' 'High' 'Main10' 'MainStillPicture+' ) Value = 'Main' } } return New-DynamicParameterSet -ParameterTable $DynamicParameters } Begin { Write-Debug "[Update-CTMediaProfile] Started" $CameraType = $PSBoundParameters.CameraType $Encoding = $PSBoundParameters.Encoding $Resolution = $PSBoundParameters.Resolution $PriorityType = $PSBoundParameters.PriorityType $BitrateControlType = $PSBoundParameters.BitrateControlType $H26xProfile = $PSBoundParameters.H26xProfile #Validate Parameters if($H26xProfile -and !$Encoding.contains('H26')) { Throw "Cannot set H.26x profile on non-H.26x Encoding" } if($CameraType -eq 'Hanwha') { #Set basic Paramters for Invoke-HanwhaCommand $CamCmd = @{ Arguments = @{ IP = $IP Menu = 'media' SubMenu = 'videoprofile' Action = 'update' Parameters = @() } Credential = $Credential } #Add Action Parameters $CamCmd.Arguments.Parameters += "Channel=$Channel" $CamCmd.Arguments.Parameters += "Profile=$ProfileID" $CamCmd.Arguments.Parameters += "EncodingType=$Encoding" if($Resolution) { $CamCmd.Arguments.Parameters += "Resolution=$Resolution" } if($FrameRate) { $CamCmd.Arguments.Parameters += "FrameRate=$FrameRate" } if($BitRate) { $CamCmd.Arguments.Parameters += "Bitrate=$Bitrate" } if($NewName) { $CamCmd.Arguments.Parameters += "Name=$NewName" } if($H26xProfile) { $CamCmd.Arguments.Parameters += "$Encoding.Profile=$H26xProfile" } if($BitrateControlType) { $CamCmd.Arguments.Parameters += "$Encoding.BitrateControlType=$BitrateControlType" } if($PriorityType) { $CamCmd.Arguments.Parameters += "$Encoding.PriorityType=$PriorityType" } Invoke-HanwhaCommand @CamCmd } } } |