Preserve extension quality with original segments and reliable refinement

This commit is contained in:
Towsty
2026-09-08 06:25:40 -05:00
parent c2b6032e49
commit 7665285a0d
16 changed files with 222 additions and 98 deletions
+7 -9
View File
@@ -125,7 +125,7 @@ export async function beginExtendFromClip(params: {
const height = source.height || 768
const clipName = String(params.name || '').trim() || nextFamilyPartName(params.ownerKey, source)
const refineExtensionFrame = parseRefineExtensionFrame(params.refineExtensionFrame, true)
const saveLosslessAnchor = parseSaveLosslessAnchor(params.saveLosslessAnchor, false)
const saveLosslessAnchor = parseSaveLosslessAnchor(params.saveLosslessAnchor, true)
const refinementDenoise = clampRefinementDenoise(params.refinementDenoise, REFINEMENT_DENOISE_DEFAULT)
const job = createJob()
@@ -252,7 +252,6 @@ async function runExtend(
})
})
const done = watchComfyJob(job)
if (params.refineExtensionFrame !== false) {
emitJob(job, {
type: 'status',
@@ -268,19 +267,18 @@ async function runExtend(
seed: params.seed,
clientId: job.clientId,
jobId: job.id,
onQueued: (promptId) => { job.promptId = promptId },
onStatus: (message) => emitJob(job, { type: 'status', message, progress: 4 })
})
writeFileSync(params.framePath, frame)
} catch (error) {
const detail = error instanceof Error ? error.message : String(error)
emitJob(job, {
type: 'status',
message: `Frame refine skipped (${detail}). Using source frame.`,
progress: 4
})
throw new Error(`Extension frame refinement failed: ${error instanceof Error ? error.message : String(error)}. Retry after fixing refinement, or explicitly turn it off.`)
}
}
if (job.status === 'cancelled' || job.status === 'error') throw new Error('Extension stopped before video generation')
job.promptId = undefined
const done = watchComfyJob(job)
job.status = 'uploading'
emitJob(job, { type: 'status', message: 'Uploading last frame to ComfyUI...', progress: 5 })
const uploaded = await uploadImage({ filename: 'last_frame.png', data: frame, type: 'image/png' }, job.id)
@@ -310,7 +308,7 @@ async function runExtend(
workflow: job.library?.workflow,
duration: job.library?.duration,
loraStack: params.loraStack || job.library?.loraStack || params.loraName || job.library?.loraName,
saveLosslessAnchor: params.saveLosslessAnchor === true || job.library?.saveLosslessAnchor === true
saveLosslessAnchor: (params.saveLosslessAnchor ?? job.library?.saveLosslessAnchor) !== false
})
const queued = await queuePrompt(graph, job.clientId)