-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Get-FFMpeg.ps1
71 lines (61 loc) · 2.05 KB
/
Get-FFMpeg.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
function Get-FFMpeg
{
<#
.Synopsis
Gets FFMpeg
.Description
Gets FFMpeg, if installed
.Example
Get-FFMpeg
.Link
Use-FFMpeg
.Link
Get-RoughDraftExtension
#>
[Outputtype([string])]
[CmdletBinding(DefaultParameterSetName='GetFFMpegPath')]
param(
# The path to FFMpeg
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$FFMpegPath
)
dynamicParam {
Get-RoughDraftExtension -CommandName $MyInvocation.MyCommand -DynamicParameter
}
process {
if ($PSCmdlet.ParameterSetName -ne 'GetFFMpegPath') {
$ffmpeg = Get-FFMpeg -FFMpegPath $FFMpegPath
#region Handle Extensions
$PSBoundParameters['InputPath'] = "$in"
Get-RoughDraftExtension -CommandName $MyInvocation.MyCommand -Run -ExtensionParameter (@{} + $PSBoundParameters) -Stream
return
}
if ($script:KnownFFMpegPath) {
return $script:KnownFFMpegPath
}
if ($ffMpegPath) {
$ffMpegAtPath = $ExecutionContext.SessionState.InvokeCommand.GetCommand($ffMpegPath, 'Application')
if ($ffMpegAtPath) {
$script:KnownFFMpegPath = $ffMpegAtPath.Source
return $script:KnownFFMpegPath
}
}
$ffMpegInPath = $ExecutionContext.SessionState.InvokeCommand.GetCommand('ffmpeg', 'Application')
if ($ffMpegInPath) {
$script:KnownFFMpegPath = $ffMpegInPath.Source
return $script:KnownFFMpegPath
}
if ($env:ProgramFiles) {
$ffMpegInProgramFiles =
$ExecutionContext.SessionState.InvokeCommand.GetCommand((
Join-Path (Join-Path (Join-Path $env:ProgramFiles ffmpeg) 'bin') 'ffmpeg.exe'
), 'Application')
if ($ffMpegInProgramFiles) {
$script:KnownFFMpegPath = $ffMpegInProgramFiles.Source
return $script:KnownFFMpegPath
}
}
throw "Cannot find ffmpeg"
}
}