Skip to content

Commit 44e10b2

Browse files
Merge pull request #65 from StartAutomating/obs-powershell-updates
obs-powershell 0.1.6
2 parents 19a8ecf + 4d5263d commit 44e10b2

File tree

160 files changed

+1338
-1544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+1338
-1544
lines changed

Assets/obs-powershell.svg

Lines changed: 2 additions & 2 deletions
Loading

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## obs-powershell 0.1.6:
2+
3+
* Adding OBS.SceneItem .Scale (Fixes #64)
4+
* OBS.SceneItem .FitToScreen, adjusting .Scale (Fixes #63)
5+
* Add-OBSMediaSource: Fixing -InputSettings / -SceneItemEnabled (Fixes #62)
6+
7+
---
8+
9+
110
## obs-powershell 0.1.5:
211

312
* Adding OBS.SceneItem .Animate (Fixes #59)

Commands/Sources/Add-OBSMediaSource.ps.ps1

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,40 @@ function Add-OBSMediaSource
105105

106106
$FilePathItem = Get-Item -Path $FilePath
107107
$myParameterData['local_file'] = $FilePathItem.FullName -replace '/', '\'
108+
109+
if ($myParameters['InputSettings']) {
110+
$keys =
111+
@(if ($myParameters['InputSettings'] -is [Collections.IDictionary]) {
112+
$myParameters['InputSettings'].Keys
113+
} else {
114+
foreach ($prop in $myParameters['InputSettings'].PSObject.Properties) {
115+
$prop.Name
116+
}
117+
})
118+
119+
foreach ($key in $keys) {
120+
$myParameterData[$key] = $myParameters['InputSettings'].$key
121+
}
122+
123+
$myParameterData.remove('inputSettings')
124+
}
108125

109126
if (-not $Name) {
110127
$Name = $FilePathItem.Name
111128
}
112129

113-
$outputAddedResult = Add-OBSInput -sceneName $myParameters["Scene"] -inputKind "ffmpeg_source" -inputSettings $myParameterData -inputName $Name
130+
$addSplat = [Ordered]@{
131+
sceneName = $myParameters["Scene"]
132+
inputKind = "ffmpeg_source"
133+
inputSettings = $myParameterData
134+
inputName = $Name
135+
}
136+
137+
if ($myParameters.Contains('SceneItemEnabled')) {
138+
$addSplat.SceneItemEnabled = $myParameters['SceneItemEnabled'] -as [bool]
139+
}
140+
141+
$outputAddedResult = Add-OBSInput @addSplat
114142
if ($outputAddedResult) {
115143
Get-OBSSceneItem -sceneName $myParameters["Scene"] |
116144
Where-Object SourceName -eq $name

Commands/Sources/Add-OBSMediaSource.ps1

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,34 @@ dynamicParam {
128128
}
129129
$FilePathItem = Get-Item -Path $FilePath
130130
$myParameterData['local_file'] = $FilePathItem.FullName -replace '/', '\'
131+
if ($myParameters['InputSettings']) {
132+
$keys =
133+
@(if ($myParameters['InputSettings'] -is [Collections.IDictionary]) {
134+
$myParameters['InputSettings'].Keys
135+
} else {
136+
foreach ($prop in $myParameters['InputSettings'].PSObject.Properties) {
137+
$prop.Name
138+
}
139+
})
140+
foreach ($key in $keys) {
141+
$myParameterData[$key] = $myParameters['InputSettings'].$key
142+
}
143+
$myParameterData.remove('inputSettings')
144+
}
131145

132146
if (-not $Name) {
133147
$Name = $FilePathItem.Name
134148
}
135-
$outputAddedResult = Add-OBSInput -sceneName $myParameters["Scene"] -inputKind "ffmpeg_source" -inputSettings $myParameterData -inputName $Name
149+
$addSplat = [Ordered]@{
150+
sceneName = $myParameters["Scene"]
151+
inputKind = "ffmpeg_source"
152+
inputSettings = $myParameterData
153+
inputName = $Name
154+
}
155+
if ($myParameters.Contains('SceneItemEnabled')) {
156+
$addSplat.SceneItemEnabled = $myParameters['SceneItemEnabled'] -as [bool]
157+
}
158+
$outputAddedResult = Add-OBSInput @addSplat
136159
if ($outputAddedResult) {
137160
Get-OBSSceneItem -sceneName $myParameters["Scene"] |
138161
Where-Object SourceName -eq $name
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
$videoSettings = Get-OBSVideoSettings
22

3-
$this | Set-OBSSceneItemTransform -SceneItemTransform ([PSCustomObject][Ordered]@{
3+
$thisTransform = $this | Get-OBSSceneItemTransform
4+
5+
$sceneItemTransform = ([Ordered]@{
46
alignment = 0
5-
height = $videoSettings.outputHeight
7+
scaleX = ([double]$videoSettings.outputWidth / $thisTransform.sourceWidth )
68
positionX = [int]($videoSettings.outputWidth / 2)
79
positionY = [int]($videoSettings.outputHeight / 2)
8-
width = $videoSettings.outputWidth
9-
})
10+
scaleY = ([double]$videoSettings.outputHeight / $thisTransform.sourceHeight )
11+
})
12+
13+
$this | Set-OBSSceneItemTransform -SceneItemTransform $sceneItemTransform
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
param(
2+
[double[]]
3+
$ScaleX = 1,
4+
5+
[double[]]
6+
$ScaleY = 1,
7+
8+
# The timespan the animation will take
9+
[TimeSpan]
10+
$TimeSpan = [timespan]::fromSeconds(1)
11+
)
12+
13+
if ($scaleX.Length -eq 1 -and $scaleY.Length -eq 1) {
14+
$this | Set-OBSSceneItemTransform -SceneItemTransform @{
15+
scaleX = $ScaleX[0]
16+
scaleY = $scaleY[0]
17+
}
18+
return
19+
}
20+
21+
$thisTransform = $this | Get-OBSSceneItemTransform
22+
23+
$fromValue = [Ordered]@{
24+
scaleX = $thisTransform.scaleX
25+
scaleY = $thisTransform.scaleY
26+
}
27+
28+
$durationPerStep = [TimeSpan]::FromMilliseconds($TimeSpan.TotalMilliseconds / $ScaleX.Length)
29+
30+
for ($stepNumber = 0; $stepNumber -lt $ScaleX.Length; $stepNumber++) {
31+
$toValue = [Ordered]@{
32+
scaleX = $ScaleX[$stepNumber]
33+
scaleY = $ScaleY[$stepNumber]
34+
}
35+
$this.Animate($fromValue, $toValue, $durationPerStep)
36+
$fromValue = $toValue
37+
}
38+

docs/Add-OBSBrowserSource.md

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ If the uri points to a local file, this will be preferred
2424

2525

2626

27-
> **Type**: ```[Uri]```
2827

29-
> **Required**: false
3028

31-
> **Position**: 1
3229

33-
> **PipelineInput**:true (ByPropertyName)
30+
|Type |Required|Position|PipelineInput |
31+
|-------|--------|--------|---------------------|
32+
|`[Uri]`|false |1 |true (ByPropertyName)|
3433

3534

3635

@@ -42,13 +41,12 @@ If none is provided, this will be the output width of the video settings.
4241

4342

4443

45-
> **Type**: ```[Int32]```
4644

47-
> **Required**: false
4845

49-
> **Position**: 2
5046

51-
> **PipelineInput**:true (ByPropertyName)
47+
|Type |Required|Position|PipelineInput |
48+
|---------|--------|--------|---------------------|
49+
|`[Int32]`|false |2 |true (ByPropertyName)|
5250

5351

5452

@@ -60,13 +58,12 @@ If none is provided, this will be the output height of the video settings.
6058

6159

6260

63-
> **Type**: ```[Int32]```
6461

65-
> **Required**: false
6662

67-
> **Position**: 3
6863

69-
> **PipelineInput**:true (ByPropertyName)
64+
|Type |Required|Position|PipelineInput |
65+
|---------|--------|--------|---------------------|
66+
|`[Int32]`|false |3 |true (ByPropertyName)|
7067

7168

7269

@@ -77,13 +74,12 @@ The css style used to render the browser page.
7774

7875

7976

80-
> **Type**: ```[String]```
8177

82-
> **Required**: false
8378

84-
> **Position**: 4
8579

86-
> **PipelineInput**:true (ByPropertyName)
80+
|Type |Required|Position|PipelineInput |
81+
|----------|--------|--------|---------------------|
82+
|`[String]`|false |4 |true (ByPropertyName)|
8783

8884

8985

@@ -94,13 +90,12 @@ If set, the browser source will shutdown when it is hidden
9490

9591

9692

97-
> **Type**: ```[Switch]```
9893

99-
> **Required**: false
10094

101-
> **Position**: named
10295

103-
> **PipelineInput**:true (ByPropertyName)
96+
|Type |Required|Position|PipelineInput |
97+
|----------|--------|--------|---------------------|
98+
|`[Switch]`|false |named |true (ByPropertyName)|
10499

105100

106101

@@ -111,13 +106,12 @@ If set, the browser source will restart when it is activated.
111106

112107

113108

114-
> **Type**: ```[Switch]```
115109

116-
> **Required**: false
117110

118-
> **Position**: named
119111

120-
> **PipelineInput**:true (ByPropertyName)
112+
|Type |Required|Position|PipelineInput |
113+
|----------|--------|--------|---------------------|
114+
|`[Switch]`|false |named |true (ByPropertyName)|
121115

122116

123117

@@ -128,13 +122,12 @@ If set, audio from the browser source will be rerouted into OBS.
128122

129123

130124

131-
> **Type**: ```[Switch]```
132125

133-
> **Required**: false
134126

135-
> **Position**: named
136127

137-
> **PipelineInput**:true (ByPropertyName)
128+
|Type |Required|Position|PipelineInput |
129+
|----------|--------|--------|---------------------|
130+
|`[Switch]`|false |named |true (ByPropertyName)|
138131

139132

140133

@@ -145,13 +138,12 @@ If provided, the browser source will render at a custom frame rate.
145138

146139

147140

148-
> **Type**: ```[Int32]```
149141

150-
> **Required**: false
151142

152-
> **Position**: 5
153143

154-
> **PipelineInput**:true (ByPropertyName)
144+
|Type |Required|Position|PipelineInput |
145+
|---------|--------|--------|---------------------|
146+
|`[Int32]`|false |5 |true (ByPropertyName)|
155147

156148

157149

@@ -163,13 +155,12 @@ If no scene name is provided, the current program scene will be used.
163155

164156

165157

166-
> **Type**: ```[String]```
167158

168-
> **Required**: false
169159

170-
> **Position**: 6
171160

172-
> **PipelineInput**:true (ByPropertyName)
161+
|Type |Required|Position|PipelineInput |
162+
|----------|--------|--------|---------------------|
163+
|`[String]`|false |6 |true (ByPropertyName)|
173164

174165

175166

@@ -181,13 +172,12 @@ If no name is provided, the last segment of the URI or file path will be the inp
181172

182173

183174

184-
> **Type**: ```[String]```
185175

186-
> **Required**: false
187176

188-
> **Position**: 7
189177

190-
> **PipelineInput**:true (ByPropertyName)
178+
|Type |Required|Position|PipelineInput |
179+
|----------|--------|--------|---------------------|
180+
|`[String]`|false |7 |true (ByPropertyName)|
191181

192182

193183

docs/Add-OBSColorSource.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ If no scene name is provided, the current program scene will be used.
2424

2525

2626

27-
> **Type**: ```[String]```
2827

29-
> **Required**: false
3028

31-
> **Position**: 1
3229

33-
> **PipelineInput**:true (ByPropertyName)
30+
|Type |Required|Position|PipelineInput |
31+
|----------|--------|--------|---------------------|
32+
|`[String]`|false |1 |true (ByPropertyName)|
3433

3534

3635

@@ -42,26 +41,24 @@ If no name is provided, "Display $($Monitor + 1)" will be the input source name.
4241

4342

4443

45-
> **Type**: ```[String]```
4644

47-
> **Required**: false
4845

49-
> **Position**: 2
5046

51-
> **PipelineInput**:true (ByPropertyName)
47+
|Type |Required|Position|PipelineInput |
48+
|----------|--------|--------|---------------------|
49+
|`[String]`|false |2 |true (ByPropertyName)|
5250

5351

5452

5553
---
5654
#### **Color**
5755

58-
> **Type**: ```[String]```
5956

60-
> **Required**: false
6157

62-
> **Position**: 3
6358

64-
> **PipelineInput**:true (ByPropertyName)
59+
|Type |Required|Position|PipelineInput |
60+
|----------|--------|--------|---------------------|
61+
|`[String]`|false |3 |true (ByPropertyName)|
6562

6663

6764

0 commit comments

Comments
 (0)