Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiencode.ps1
More file actions
Latest commit
59 lines (55 loc) · 2.62 KB
/
Copy pathmultiencode.ps1
File metadata and controls
59 lines (55 loc) · 2.62 KB
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
param(
[Parameter(Mandatory=$true)][string]$i=".jpg",
[Parameter(Mandatory=$true)][string]$o=".webp",
[int]$jobs,
[string]$ve,
[string]$vc,
[string]$ae,
[string]$ac
)
if ($jobs-eq0) {
if ($IsWindows) {
$jobs= (Get-CimInstance-ClassName 'Win32_ComputerSystem').NumberOfLogicalProcessors
} elseif ($IsMacOS) {
$jobs= sysctl -n hw.ncpu
} else {
$jobs=grep.exe-c ^processor /proc/cpuinfo
}
}
Get-Item ('*'+$i) |ForEach-Object {
$Check=$false
while ($Check-eq$false) {
if ((Get-Job-State 'Running').Count -ne8) {
Start-Job-ArgumentList $_,$i,$o,$ve,$vc,$ae,$ac-ScriptBlock {
param($inputfile,$informat,$outformat,$ve,$vc,$ae,$ac);
$infile=Get-Item$inputfile
$audioencoder= ("-c:a "+$ae)
$videoencoder= ("-c:v "+$ve)
if ([string]::IsNullOrEmpty($ve)) {
if ([string]::IsNullOrEmpty($ae)) {
Write-Output"w/o both"
ffmpeg.exe-threads 8-y -i $infile.FullName$infile.FullName.Replace($infile.Extension,$outformat)
} else {
Write-Output"w/o video"
ffmpeg.exe-threads 8-y -i $infile.FullName$audioencoder$infile.FullName.Replace($infile.Extension,$outformat)
}
} else {
if ([string]::IsNullOrEmpty($ae)) {
Write-Output"w/o audio"
Write-Output$videoencoder
Write-Output$vc
ffmpeg.exe-threads 8-v 100-y -i $infile.FullName-c:v $ve-lossless:v 1-pix_fmt bgra $infile.FullName.Replace($infile.Extension,$outformat)
} else {
Write-Output"w both"
ffmpeg.exe-threads 8-y -i $infile.FullName$videoencoder$audioencoder$infile.FullName.Replace($infile.Extension,$outformat)
}
}
# Write-Output $infile.FullName $videoencoder $audioencoder ((join-path $infile.DirectoryName $infile.BaseName) + $outformat)
# ffmpeg -threads 8 -y -i $infile.FullName $videoencoder $audioencoder ((join-path $infile.DirectoryName $infile.BaseName) + $outformat)
# $inputfile.FullName.Replace($inputfile.Extension,$('.' + $outf))
}
$Check=$true
}
}
# Remove-Job -State Completed
}