Progress update
This commit is contained in:
parent
15f8f4b53b
commit
614e2111f1
@ -85,8 +85,7 @@ class ProgressDecoder(val workBase: WorkBase) {
|
||||
if (duration == null)
|
||||
return Progress(workId = workBase.workId, outFileName = File(workBase.outFile).name, duration = durationTime, time = "NA", speed = "NA")
|
||||
val progressTime = timeSpanToSeconds(decoded.out_time) ?: 0
|
||||
val diff = floor(progressTime.toDouble() / duration!!.toDouble())
|
||||
val progress = floor(diff*100).toInt()
|
||||
val progress = floor((progressTime.toDouble() / duration!!.toDouble()) *100).toInt()
|
||||
|
||||
val ect = getEstimatedTimeRemaining(decoded)
|
||||
|
||||
|
||||
@ -51,17 +51,16 @@ class RunnerCoordinator(private var maxConcurrentJobs: Int = 1) {
|
||||
logger.info("Worker is waiting for a work item...")
|
||||
val workItem = queue.receive() // Coroutine will wait here until a work item is available
|
||||
logger.info("Worker received a work item.")
|
||||
if (jobsInProgress.get() <= maxConcurrentJobs) {
|
||||
if (jobsInProgress.get() < maxConcurrentJobs) {
|
||||
jobsInProgress.incrementAndGet()
|
||||
val job = processWorkItem(workItem)
|
||||
inProgressJobs.add(job)
|
||||
job.invokeOnCompletion {
|
||||
val currentJobsInProgress = jobsInProgress.decrementAndGet()
|
||||
logger.info { "Available workers: ${maxConcurrentJobs - currentJobsInProgress}" }
|
||||
logger.info { "Available workers: ${jobsInProgress.decrementAndGet()}/${maxConcurrentJobs}" }
|
||||
inProgressJobs.remove(job)
|
||||
}
|
||||
}
|
||||
logger.info { "Available workers: ${maxConcurrentJobs - jobsInProgress.get()}" }
|
||||
logger.info { "Available workers: ${jobsInProgress.get()}/$maxConcurrentJobs" }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,6 +116,36 @@ class DecodedProgressDataDecoderTest {
|
||||
assertThat(progress.progress).isGreaterThanOrEqualTo(99)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testThatProgressIsNotNone() {
|
||||
val encodeWork = EncodeWork(
|
||||
workId = UUID.randomUUID().toString(),
|
||||
collection = "Demo",
|
||||
inFile = "Demo.mkv",
|
||||
outFile = "FancyDemo.mp4",
|
||||
arguments = emptyList()
|
||||
)
|
||||
val decoder = ProgressDecoder(encodeWork)
|
||||
decoder.setDuration("Duration: 01:48:54.82,")
|
||||
assertThat(decoder.duration).isNotNull()
|
||||
val decodedProgressData = DecodedProgressData(
|
||||
frame = null,
|
||||
fps = null,
|
||||
stream_0_0_q = null,
|
||||
bitrate = null,
|
||||
total_size = null,
|
||||
out_time_ms = null,
|
||||
out_time_us = null,
|
||||
out_time = "01:00:50.174667",
|
||||
dup_frames = null,
|
||||
drop_frames = null,
|
||||
speed = 1.0,
|
||||
progress = "Continue"
|
||||
)
|
||||
val progress = decoder.getProgress(decodedProgressData)
|
||||
assertThat(progress.progress).isGreaterThanOrEqualTo(1)
|
||||
}
|
||||
|
||||
val text = """
|
||||
frame=16811 fps= 88 q=40.0 size= 9984kB time=00:x01:10.79 bitrate=1155.3kbits/s speed=3.71x
|
||||
fps=88.03
|
||||
|
||||
Loading…
Reference in New Issue
Block a user