-
Notifications
You must be signed in to change notification settings - Fork 0
/
StingerFixer.ps1
68 lines (54 loc) · 2.38 KB
/
StingerFixer.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
#push script location
$scriptPath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptPath
Push-Location $dir
#loading functions
#load helpers
. .\helpers\banner.ps1
. .\helpers\ffmpegInfo.ps1
. .\helpers\commonFunctions.ps1
#settings
$ll = 24 #loglevel, set 32 if you want normal output. This (24) will only show warnings.
$ow = "n" #overwrite files in output dir. Switch to "y" (yes), if you would like.
$suffix = "vp9fix" #name that is used as a suffix for files in the output folder. Easier to tell them apart, and lower risk of overwriting.
#
### Stop editing stuff now, unless you are every confident in your changes :)
#
write-host "Stinger fixer. Re-encodes potentially wonky alpha videos" -ForegroundColor Magenta -BackgroundColor black
write-host "`r"
write-host "`r"
Write-Host "Please select the stinger file" -ForegroundColor Yellow
$video = read-host -Prompt "`nPlease drag&drop a video, then hit Enter" #drag video in
$inputStinger = get-childitem -path ($video -replace '"', "") #input is dumbass string, fix it
Clear-Host
# naming stuff
Set-FileVars($inputStinger) #full=wPath, base=noExt,
#$inputCodec = ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 $inputStinger
$inputCodec = Get-InputCodec -inputFile $inputStinger
write-host "Processing, please be patient" -ForegroundColor Yellow
$outFile = "$dir\$baseName-$suffix.webm"
$startTime = get-date
if ($inputCodec -eq "vp9") {
write-host "vp9, ensuring correct decoder" -ForegroundColor Yellow
ffmpeg -$ow -loglevel $ll -c:v libvpx-vp9 -i "$inputStinger" `
-c:v libvpx-vp9 -crf 31 -b:v 0 -b:a 192k -cpu-used 5 `
-pix_fmt yuva420p $outFile
} elseif ($inputCodec -eq "vp8") {
write-host "vp8, ensuring correct decoder" -ForegroundColor Yellow
ffmpeg -$ow -loglevel $ll -c:v libvpx -i "$inputStinger" `
-c:v libvpx-vp9 -crf 31 -b:v 0 -b:a 192k -cpu-used 5 `
-pix_fmt yuva420p $outFile
} else {
Write-Host "not a webm, trying auto" -ForegroundColor Yellow
ffmpeg -$ow -loglevel $ll -i "$inputStinger" `
-c:v libvpx-vp9 -crf 31 -b:v 0 -b:a 192k -cpu-used 5 `
-pix_fmt yuva420p $outFile
}
$endTime = get-date
$time = new-timespan -start $startTime -End $endTime
write-host "`r"
Write-host "Done! Completed in: $time" -ForegroundColor Magenta
Write-Host "Please test $outfile" -ForegroundColor Green
Pop-Location
psPause
exit 0