-
Notifications
You must be signed in to change notification settings - Fork 7
/
Convert-ARF.ps1
334 lines (306 loc) · 14 KB
/
Convert-ARF.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<#
.SYNOPSIS
Converts ARF files to the specified format.
.DESCRIPTION
Long description
.EXAMPLE
PS C:\> .\Convert-ARF.ps1
Explanation of what the example does
.INPUTS
Inputs (if any)
.OUTPUTS
Output (if any)
.COMPONENT
The component this cmdlet belongs to
.ROLE
The user's company role this cmdlet is designed for
.FUNCTIONALITY
The functionality that best describes this cmdlet
???
.LINK
https://github.com/elliot-labs/PowerShell-Doodads
.NOTES
This script only runs on Windows currently
#>
# [OutputType([System.String])]
[CmdletBinding(DefaultParameterSetName = 'MP4')]
param (
[ValidateSet("MP4", "WMV", "SWF")]
[System.String]$OutputType = "MP4"
)
begin {
# Define the INI file configuration options class
class Global_Options {
[System.String]$InputFile
[System.String]$OutputFile
[System.String]$MediaType
[System.Boolean]$ShowUI
[System.Int64]$Width
[System.Int64]$Height
}
class MP4_Options {
[System.Boolean]$Chat
[System.Boolean]$Video
[System.Boolean]$QuestionAnswer
[System.Boolean]$LargeOutLine = $True
[System.Int64]$FrameRate
}
class WMV_Options {
[System.Boolean]$PCAudio = $False
[System.Boolean]$Chat = $False
[System.Boolean]$Video = $False
[System.Boolean]$LargerOutline = $True
[System.String]$VideoCodec
[System.String]$AudioCodec
[System.String]$VideoFormat = "default"
[System.String]$AudioFormat = "default"
[System.Int64]$VideoKeyFrames
[System.Int64]$MaxStream
}
class SWF_Options {
[System.Boolean]$PCAudio = $True
[System.Int64]$FrameRate
}
class INI_Options {
[Global_Options]$GlobalOptions
$FileTypeOptions
INI_Options([Global_Options]$GlobalOption, [MP4_Options]$MP4Option){
$this.GlobalOptions = $GlobalOption
$this.FileTypeOptions = $MP4Option
}
INI_Options([Global_Options]$GlobalOption, [WMV_Options]$WMVOption){
$this.GlobalOptions = $GlobalOption
$this.FileTypeOptions = $WMVOption
}
INI_Options([Global_Options]$GlobalOption, [SWF_Options]$SWFOption){
$this.GlobalOptions = $GlobalOption
$this.FileTypeOptions = $SWFOption
}
}
function Test-NBRPrerequisite {
<#
.SYNOPSIS
Checks if the pre-requisites are installed on the machine.
.DESCRIPTION
Tests to see if the NBR player is present on the system.
Throws an error if it is not present stating that the user needs to specify the value themselves or install it on the system.
.PARAMETER Path
A path to the NBR player executable.
Input is validated and will be returned if input is valid.
.EXAMPLE
PS C:\> Test-Prerequisite.
Checks the system to see if NBR player is installed and if it is, it will return the path to the specific install location.
If it is not installed, it will throw an error stating that the NBR player can't be found and has instruction on how to install it.
If the system is not running windows, it will write a warning.
.EXAMPLE
PS C:\> Test-Prerequisite -Path "C:\Some\Path\nbrplay.exe"
Check to see if the specified path is valid, if it is, it will return the same path specified.
Since the parameter has validation, powershell itself will handle the error.
If the system is not running windows, it will write a warning.
.INPUTS
System.String
.OUTPUTS
System.String
.NOTES
The nbr player can be installed from:
https://www.webex.com/play-webex-recording.html
#>
# Define the parameter
param (
# Path to the NBR Player executable.
# Validates if the path is a leaf as the executable will be a leaf.
[Parameter(
Mandatory = $false,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true
)]
[ValidateNotNullOrEmpty()]
[ValidateScript( { Test-Path $_ -PathType "Leaf" })]
[System.String]$Path
)
# If there is no user input, test to see if the player is installed
if ($null -eq $Path) {
# Test to see if the NBR player executable is present in the 32bit program folder for 64bit Windows
if (Test-Path -Path "C:\Program Files (x86)\Webex\Webex\500\nbrplay.exe") {
$Path = "C:\Program Files (x86)\Webex\Webex\500\nbrplay.exe"
}
# Test to see if the NBR player executable is present in the program folder for 32bit Windows
elseif (Test-Path -Path "C:\Program Files\Webex\Webex\500\nbrplay.exe") {
$Path = "C:\Program Files\Webex\Webex\500\nbrplay.exe"
}
# Test to see if the NBR player executable is present legacy NBR location
elseif (Test-Path -Path "C:\ProgramData\WebEx\WebEx\500\nbrplay.exe") {
# Set the variable to be equal to the
$Path = "C:\ProgramData\WebEx\WebEx\500\nbrplay.exe"
}
# If all check fail, notify the user that they have to specify the path themselves and halt execution
else {
# Terminate execution and return information on why execution was terminated
throw "NBR Player not found. Please specify the location of nbrplay.exe.
Use the -NBRPath parameter to achieve this.
If it is not installed, please install it by going to www.webex.com/play-webex-recording.html"
}
}
# Check to see if the script is running on Windows
# Throw an error if it isn't
if ($PSVersionTable.Platform -ne "Win32NT") {
# Write an error to the console host
Write-Warning -Message "This is only supported on Windows, running this on other platforms is at your own risk!"
}
# Return the path to the nbr player after validation has succeeded.
return $Path
}
function Test-MP4Prerequisite {
<#
.SYNOPSIS
Tests to see if the MP4 libraries are present.
.DESCRIPTION
Takes the specified path to the nbr install and validates if the MP4 libraries are installed or not.
If it is not able to find the MP4 libs, it returns false, if it can find them it is successful.
.PARAMETER NBRPath
This parameter takes a path to the NBR player's installation directory.
It validates that the specified path is present and is a directory.
The correct directory has the "webex.exe" file located in it.
.EXAMPLE
PS C:\> Test-MP4Prerequisite -NBRPath "C:\Program Files (x86)\Webex\"
Checks relative to the specified directory for the MP4 libs.
If the plugin directory is not present then it creates the directory and returns false.
If the plugin directory exists then the directory is checked for the appropriate DLLs.
If the DLLs are indeed present then $true is returned.
.INPUTS
System.String
.OUTPUTS
System.Boolean
.NOTES
Returns $False if the required files could not be found.
Returns $True if the required files could be found.
Writes an error if it could not create the required folder for the MP4 DLLs.
This is non terminating.
#>
#Requires -RunAsAdministrator
param (
[Parameter(
Mandatory = $true,
Position = 0,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $true
)]
[ValidateScript( { Test-Path "$_\webex.exe" -PathType "Leaf" })]
[System.String]$NBRPath
)
process {
# Checks to see if the Plugin directory is present before checking for the MP4 libraries.
if (-not (Test-Path -Path "$NBRPath\Webex\500\Plugin" -PathType "Container")) {
# Write warning messages to the end user if the the path doesn't exist.
# This means that the correct directory would not exist and the user would need to set up the MP4 libs.
Write-Warning -Message "The MP4 DLLs are not present, please download and place them into the plugin folder here: $NBRPath\Webex\500\Plugin"
Write-Warning -Message "You can download the MP4 libraries here: https://cisco.bravais.com/s/0ovsmxyXiqUxhn0vSSUb"
Write-Warning -Message "You can learn more here: https://help.webex.com/en-us/WBX56022/Prompted-to-Enter-URL-Account-Name-and-Password-when-Converting-an-NBR-to-MP4-Format"
# Catch errors on directory creation so that errors can be handled gracefully.
try {
# Create the Plugin folder for the end user to place the MP4 files into.
New-Item -Path "$NBRPath\Webex\500\Plugin" -ItemType "Directory"
}
catch {
# Could not create the directory for some reason, write an error.
Write-Error -Message "Failed to create the plugin directory."
}
# Return false indicating that the test has failed to find the required MP4 files.
return $false
}
elseif (-not (Test-Path -Path "$NBRPath\Webex\500\Plugin\atgpcext.dll" -PathType "Leaf")) {
# Write warning messages to the end user if the the path doesn't exist.
# This means that the correct directory would not exist and the user would need to set up the MP4 libs.
Write-Warning -Message "The Download Module DLL is not present, please download and place it into the plugin folder here: $NBRPath\Webex\500\Plugin"
Write-Warning -Message "You can download the MP4 libraries here: https://cisco.bravais.com/s/0ovsmxyXiqUxhn0vSSUb"
Write-Warning -Message "You can learn more here: https://help.webex.com/en-us/WBX56022/Prompted-to-Enter-URL-Account-Name-and-Password-when-Converting-an-NBR-to-MP4-Format"
return $false
}
elseif (-not (Test-Path -Path "$NBRPath\Webex\500\Plugin\libfaac.dll" -PathType "Leaf")) {
# Write warning messages to the end user if the the path doesn't exist.
# This means that the correct directory would not exist and the user would need to set up the MP4 libs.
Write-Warning -Message "The ffmpeg AAC DLL is not present, please download and place it into the plugin folder here: $NBRPath\Webex\500\Plugin"
Write-Warning -Message "You can download the MP4 libraries here: https://cisco.bravais.com/s/0ovsmxyXiqUxhn0vSSUb"
Write-Warning -Message "You can learn more here: https://help.webex.com/en-us/WBX56022/Prompted-to-Enter-URL-Account-Name-and-Password-when-Converting-an-NBR-to-MP4-Format"
return $false
}
else {
# Returns true if the required files are present.
return $true
}
}
}
function Export-INIConfiguration {
<#
.SYNOPSIS
Creates the config files for the NBR player's conversion system
.DESCRIPTION
Long description
.EXAMPLE
PS C:\> <example usage>
Explanation of what the example does
.INPUTS
Inputs (if any)
.OUTPUTS
Output (if any)
.NOTES
General notes
#>
param(
[ValidateNotNullOrEmpty()]
[ValidateScript( {
Test-Path -Path $_ -IsValid
})]
[System.String[]]$Path
)
begin { }
process { }
end {
foreach ($Key in $InputObject.keys) {
# If there is a hash table in the value section, make the key the section name and loop through the
# sub keys and values to create the INI section's key and values.
if ($InputObject[$Key] -Is [System.Collections.HashTable]) {
# Write the key value as the section name of the INI formatted
Add-Content -Path $Path -Value "[$Key]"
# Loop through the embedded HashTable and write the key and values to the file
foreach ($SubKey in ($InputObject[$Key].keys | Sort-Object)) {
if ($SubKey -match "^Comment[\d]+") {
Add-Content -Path $Path -Value "$($InputObject[$Key][$SubKey])"
}
else {
Add-Content -Path $Path -Value "$SubKey=$($InputObject[$Key][$SubKey])"
}
}
# Add white space to bottom of file.
Add-Content -Path $Path -Value ""
# If the key value pair does not contain a HashTable, treat it as just key and values with no section header.
}
else {
# Write the key value pairs to the specified file.
Add-Content -Path $Path -Value "$Key=$($InputObject[$Key])"
}
}
}
# Build the global config section of the config file
# $GlobalConfig = "
# [Console]
# InputFile=$InputFile
# media=$FileType
# ShowUI=$([int]$ShowUI)
# PCAudio=$([int]$PCAudio)
# [UI]
# chat=1
# qa=1
# "
}
function ConvertFrom-CiscoARF {
# Pass
}
}
process {
if ($MyInvocation.Line -NotMatch "^\.\s") {
# run script in CLI mode, not dot sourced - standalone
}
}
end {}