Last active
May 8, 2022 11:20
-
-
Save eddiezato/2096c08bdea59ddf82f92f73c7cb749e to your computer and use it in GitHub Desktop.
Test takc 2.3.0 and 2.3.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory, ValueFromPipeline, Position = 0)] | |
[ValidatePattern('\.wav$', ErrorMessage = "You should specify .wav files")] | |
[string[]]$Input, | |
[Parameter(Position = 1)][Alias('p')] | |
[uint]$Passes = 10 | |
) | |
process { | |
Class Result { | |
[string]$Version | |
[float]$Compress | |
[long]$Filesize_bytes | |
[float]$Enc_dur_sec | |
[float]$Encode_speed | |
[float]$Decode_speed | |
} | |
Get-Item -LiteralPath $Input | Foreach-Object { | |
$wavfile = $_ | |
$wavfile_info = (mediainfo --Output=JSON $($wavfile.FullName) | ConvertFrom-Json).media.track | |
$finalresults = @() | |
$finalresults += [Result]@{ | |
Version = "WAV" | |
Compress = 100 | |
Filesize_bytes = $wavfile.Length | |
} | |
"231", "232" | Foreach-Object { | |
$results = @() | |
$tak = ".\takc$_" | |
$takfile = "test$_.tak" | |
Write-Host "Version $_, $Passes passes " -NoNewLine | |
for ($i = 0; $i -lt $Passes; $i ++) { | |
Write-Host "." -NoNewLine | |
$data = & $tak -e -overwrite -p4m -md5 -tn4 $wavfile.Name $takfile | |
$data2 = & $tak -t $takfile | |
$results += [Result]@{ | |
Compress = ($data[2] -replace '[^\d\.]','') -as [float] | |
Filesize_bytes = (Get-Item -LiteralPath $takfile).Length | |
Enc_dur_sec = ($data[3] -replace '[^\d\.]','') -as [float] | |
Encode_speed = ($data[4] -replace '[^\d\.]','') -as [float] | |
Decode_speed = ($data2[3] -replace '[^\d\.]','') -as [float] | |
} | |
} | |
Write-Host | |
Remove-Item -Path $takfile | |
$finalresults += [Result]@{ | |
Version = $_ | |
Compress = [Math]::Round(($results | Measure-Object -Property Compress -Average).Average, 2) | |
Filesize_bytes = [Math]::Round(($results | Measure-Object -Property Filesize_bytes -Average).Average, 0) | |
Enc_dur_sec = [Math]::Round(($results | Measure-Object -Property Enc_dur_sec -Average).Average, 2) | |
Encode_speed = [Math]::Round(($results | Measure-Object -Property Encode_speed -Average).Average, 2) | |
Decode_speed = [Math]::Round(($results | Measure-Object -Property Decode_speed -Average).Average, 2) | |
} | |
} | |
Write-Host | |
Write-Host "$($wavfile.Name), " -NoNewLine | |
Write-Host "$("{0:hh\:mm\:ss}" -f[timespan]::fromseconds($wavfile_info[0].Duration))," -NoNewLine | |
Write-Host "$($wavfile_info.Channels) ch,$($wavfile_info.BitDepth) bit,$($wavfile_info.SamplingRate) Hz" | |
Write-Output $finalresults | Format-Table | |
Write-Host | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment