refactor(transcode): offload video embedding chunk slicing to transcode queue (#539)

* refactor(transcode): offload video embedding chunk slicing to transcode queue

* fix(transcode): address video chunk offloading review findings
This commit is contained in:
Yiling-J
2026-11-22 11:52:58 +08:00
committed by GitHub
parent 3943407093
commit aabf59cbe7
23 changed files with 1226 additions and 434 deletions
+1
View File
@@ -137,6 +137,7 @@ export class AssetArchiveService {
WorkflowTaskType.transcode_screenshot,
WorkflowTaskType.transcode_image_annotation,
WorkflowTaskType.transcode_watermark,
WorkflowTaskType.transcode_video_chunks,
],
},
},
+40
View File
@@ -5556,6 +5556,46 @@ describe('AssetService — natural sort by name', () => {
expect(restored?.isDeleted).toBe(false)
expect(restored?.status).toBe(AssetStatus.processed)
})
it('should restore asset with status "processed" even if an auxiliary transcode_video_chunks task is active', async () => {
const team = await prisma.team.create({ data: { name: 'Restore Video Chunks Team' } })
const project = await prisma.project.create({
data: { name: 'Restore Video Chunks Project', teamId: team.id },
})
const rootFolder = await prisma.asset.create({
data: {
name: 'root',
type: AssetType.folder,
projectId: project.id,
status: AssetStatus.uploaded,
},
})
const file = await prisma.asset.create({
data: {
name: 'embedding-chunks-video.mp4',
type: AssetType.file,
projectId: project.id,
parentId: rootFolder.id,
status: AssetStatus.trashed,
isDeleted: true,
deletedAt: new Date(),
},
})
await prisma.workflowTask.create({
data: {
assetId: file.id,
type: WorkflowTaskType.transcode_video_chunks,
status: WorkflowTaskStatus.processing,
},
})
await assetService.restoreAssets([file.id])
const restored = await prisma.asset.findUnique({ where: { id: file.id } })
expect(restored?.isDeleted).toBe(false)
expect(restored?.status).toBe(AssetStatus.processed)
})
})
describe('HLS playlists', () => {
@@ -166,6 +166,15 @@ describe('EmbeddingService', () => {
projectId: project.id,
},
})
const staleChunkTask = await prisma.workflowTask.create({
data: {
assetId: videoAsset.id,
type: WorkflowTaskType.transcode_video_chunks,
status: WorkflowTaskStatus.processing,
teamId: team.id,
projectId: project.id,
},
})
const initialEmbeddings = await prisma.assetEmbedding.count({
where: { assetId: videoAsset.id },
@@ -179,6 +188,12 @@ describe('EmbeddingService', () => {
expect(result.tasksCreated).toBe(3)
expect(result.skippedTeams).not.toContain('Active Embedding Team')
// Verify old transcode_video_chunks task was also wiped upfront
const remainingChunkTask = await prisma.workflowTask.findUnique({
where: { id: staleChunkTask.id },
})
expect(remainingChunkTask).toBeNull()
// Verify old embeddings were wiped upfront
const remainingEmbeddings = await prisma.assetEmbedding.count({
where: { assetId: videoAsset.id },
@@ -80,7 +80,9 @@ export class EmbeddingService {
await prisma.workflowTask.deleteMany({
where: {
assetId: { in: eligibleAssetIds },
type: WorkflowTaskType.ai_embedding,
type: {
in: [WorkflowTaskType.ai_embedding, WorkflowTaskType.transcode_video_chunks],
},
},
})