Preserve extension quality with original segments and reliable refinement
This commit is contained in:
+11
-2
@@ -1,3 +1,4 @@
|
||||
import { videoSourcePaths } from './videoSources'
|
||||
import { existsSync } from 'node:fs'
|
||||
import type { Job, JobEvent } from '~/server/utils/jobs'
|
||||
import { getJob, restoreJob } from '~/server/utils/jobs'
|
||||
@@ -221,6 +222,11 @@ export function watchComfyJob(job: Job, options: { persist?: boolean } = {}): Pr
|
||||
})
|
||||
if (job.library) {
|
||||
let buffer = await downloadComfyVideo(video)
|
||||
const originalSegment = buffer
|
||||
const parentVideo = job.library.parentClipId ? clipVideoPath(job.library.ownerKey, job.library.parentClipId) : ''
|
||||
const sourceSegments = job.library.extendPart1Path
|
||||
? videoSourcePaths(parentVideo && existsSync(parentVideo) ? parentVideo : job.library.extendPart1Path)
|
||||
: []
|
||||
let segmentFirstFrame: Buffer | undefined
|
||||
if (stitching) {
|
||||
if (!existsSync(job.library.extendPart1Path!)) {
|
||||
@@ -236,6 +242,7 @@ export function watchComfyJob(job: Job, options: { persist?: boolean } = {}): Pr
|
||||
buffer = await stitchExtension({
|
||||
part1Path: job.library.extendPart1Path!,
|
||||
part2: buffer,
|
||||
sourcePaths: sourceSegments,
|
||||
tmpDir: job.library.extendTmpDir!
|
||||
})
|
||||
}
|
||||
@@ -273,9 +280,11 @@ export function watchComfyJob(job: Job, options: { persist?: boolean } = {}): Pr
|
||||
permanenceRefs: clipRefsFromJob(job.library),
|
||||
loraName: job.library.loraName,
|
||||
loraStack: job.library.loraStack,
|
||||
segmentFirstFrame
|
||||
segmentFirstFrame,
|
||||
originalSegment,
|
||||
sourceSegments
|
||||
})
|
||||
if (job.library.saveLosslessAnchor === true) {
|
||||
if (job.library.saveLosslessAnchor !== false) {
|
||||
try {
|
||||
const { persistClipAnchorFrame, extractAnchorImageFromHistory, downloadAnchorImage } = await import('~/server/utils/extensionFrame')
|
||||
let saved = false
|
||||
|
||||
Reference in New Issue
Block a user