Finished implementing version 1.0
This commit is contained in:
parent
d99c31e7ae
commit
f625c7496f
1 changed files with 32 additions and 6 deletions
38
spav1an.ps1
38
spav1an.ps1
|
@ -5,7 +5,6 @@ param (
|
|||
[Switch] $PrintCommands,
|
||||
[int] $EncoderType = 1, # Encoder type. 1 = aomenc, 2 = SVT-AV1
|
||||
[int] $Renderer = 1, # Frame type, 1 = ffmpeg native, 2 = avisynth
|
||||
[int] $MinChunkSec = 10,
|
||||
[int] $Threads = 0,
|
||||
[int] $MaxKeyInt = 0, #
|
||||
[String] $Framerate = "auto",
|
||||
|
@ -58,6 +57,7 @@ public class ProjectContext {
|
|||
public DateTime finished;
|
||||
public DateTime eta;
|
||||
public int framestotal;
|
||||
public int framesstarted;
|
||||
public int framesfinished;
|
||||
}
|
||||
"@
|
||||
|
@ -404,6 +404,11 @@ function Watch-JobsUntilFinishes([ProjectContext] $context, [System.Collections.
|
|||
$framechunk = '0' * $context.framestotal.ToString().Length
|
||||
$workerFinished = $false
|
||||
|
||||
$seconds = ($context.finished - $context.started).TotalSeconds
|
||||
$fps = ($context.framesfinished - $context.framesstarted) / $seconds
|
||||
$etatotal = ($context.framestotal / $fps) - $seconds
|
||||
$finishedold = $context.framesfinished
|
||||
|
||||
while ($workerFinished -ne $true) {
|
||||
if ($context.muxerjob.State -eq 'Failed') {
|
||||
Write-Host "------------------------------"
|
||||
|
@ -454,15 +459,33 @@ function Watch-JobsUntilFinishes([ProjectContext] $context, [System.Collections.
|
|||
}
|
||||
|
||||
$prefix = $context.chunkformat -f $activeworkers[$x].index, $context.chunkstotal
|
||||
Write-Host (("{0,-" + [Math]::Max($Host.UI.RawUI.WindowSize.Width - 1, 0) + "}") -f "$prefix $currentprogress")
|
||||
$message = "$prefix $currentprogress"
|
||||
if ($message.Length -gt ($consolewidth - 1)) {
|
||||
$message = $message.Substring(0, $consolewidth - 1)
|
||||
}
|
||||
Write-Host (("{0,-" + [Math]::Max($Host.UI.RawUI.WindowSize.Width - 1, 0) + "}") -f $message)
|
||||
}
|
||||
$now = Get-Date
|
||||
|
||||
$howisitgoing = ("{0:" + $framechunk + "}/{1:" + $framechunk + "}") -f $context.framesfinished, $context.framestotal
|
||||
$howisitgoing = ("{0:" + $framechunk + "}/{1:" + $framechunk + "} ({2:" + $context.countformat + "}/{3:" + $context.countformat + "})") -f $context.framesfinished, $context.framestotal, $context.muxernextindex, $context.chunkstotal
|
||||
|
||||
$howisitgoing += " [{0,-30}]" -f ('#' * [Math]::Floor(($context.framesfinished/$context.framestotal) * 30))
|
||||
$howisitgoing += " [{0,-20}]" -f ('#' * [Math]::Floor(($context.framesfinished/$context.framestotal) * 20))
|
||||
|
||||
$howisitgoing += (" Muxed {0:" + $context.countformat + "}/{1:" + $context.countformat + "}") -f $context.muxernextindex, $context.chunkstotal
|
||||
# $howisitgoing += (" Muxed {0:" + $context.countformat + "}/{1:" + $context.countformat + "}") -f $context.muxernextindex, $context.chunkstotal
|
||||
|
||||
if ($finishedold -gt $context.framesstarted) {
|
||||
$howisitgoing += " fps {0:0.00}" -f $fps
|
||||
$until = $context.started.AddSeconds($etatotal) - $now
|
||||
if ($until.TotalSeconds -gt 0) {
|
||||
if ($until.Days -gt 0) {
|
||||
$howisitgoing += (" eta {0}d {1:00}:{2:00}:{3:00}" -f $until.Days, $until.Hours, $until.Minutes, $until.Seconds)
|
||||
} else {
|
||||
$howisitgoing += (" eta {1:00}:{2:00}:{3:00}" -f $until.Days, $until.Hours, $until.Minutes, $until.Seconds)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$howisitgoing += ' eta <calculating>'
|
||||
}
|
||||
|
||||
if ($context.muxerjob.State -ne 'Completed') {
|
||||
$lastmessage = $context.muxerjob.Output | Select-Object -Last 1
|
||||
|
@ -475,7 +498,6 @@ function Watch-JobsUntilFinishes([ProjectContext] $context, [System.Collections.
|
|||
$howisitgoing = $howisitgoing.Substring(0, $consolewidth - 1)
|
||||
}
|
||||
|
||||
|
||||
Write-Host (("{0,-" + $consolewidth + "}") -f " ")
|
||||
Write-Host (("{0,-" + $consolewidth + "}") -f $howisitgoing)
|
||||
|
||||
|
@ -558,6 +580,7 @@ function Start-OurEncoding {
|
|||
}
|
||||
|
||||
$context.framestotal = $project[$project.Count - 1].end + 1
|
||||
$context.framesstarted = 0
|
||||
$context.fps = $projectraw.fps
|
||||
$context.nextchunkindex = 0
|
||||
$context.muxernextindex = 0
|
||||
|
@ -601,6 +624,7 @@ function Start-OurEncoding {
|
|||
for ($i = 0; $i -lt $context.nextchunkindex; $i++) {
|
||||
$context.framesfinished += ($project[$i].end - $project[$i].start) + 1
|
||||
}
|
||||
$context.framesstarted = $context.framesfinished
|
||||
|
||||
Write-Host "Starting our chunk encoder with maximum $Threads workers"
|
||||
for ($x = 0; $x -lt $activeworkers.Count; $x++) {
|
||||
|
@ -609,6 +633,8 @@ function Start-OurEncoding {
|
|||
Write-Host ""
|
||||
Write-Host ""
|
||||
|
||||
$context.started = Get-Date
|
||||
|
||||
# repeat until done
|
||||
while ($true) {
|
||||
# If we still have some unproccessed segments left
|
||||
|
|
Loading…
Reference in a new issue