mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 21:04:59 +00:00
fix(transcode): remove debug logs, keep clean epsilon bugfix
This commit is contained in:
@@ -2,7 +2,6 @@ import { Type } from '@sinclair/typebox'
|
|||||||
import { type AgentTool } from '@earendil-works/pi-agent-core'
|
import { type AgentTool } from '@earendil-works/pi-agent-core'
|
||||||
import { type ImageContent } from '@earendil-works/pi-ai'
|
import { type ImageContent } from '@earendil-works/pi-ai'
|
||||||
import { prisma, WorkflowTaskType, WorkflowTaskStatus, type User } from '@shumai/db'
|
import { prisma, WorkflowTaskType, WorkflowTaskStatus, type User } from '@shumai/db'
|
||||||
import { logger } from '@shumai/core/src/logger'
|
|
||||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||||
import { workflowService } from '@shumai/workflow-core'
|
import { workflowService } from '@shumai/workflow-core'
|
||||||
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||||
@@ -66,18 +65,6 @@ export function createScreenshotTool(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(
|
|
||||||
{
|
|
||||||
assetId,
|
|
||||||
userId,
|
|
||||||
userCommentId,
|
|
||||||
commentTimestamp,
|
|
||||||
hasAnnotations: Boolean(annotations),
|
|
||||||
params,
|
|
||||||
},
|
|
||||||
'[screenshotTool] Executing screenshot tool call',
|
|
||||||
)
|
|
||||||
|
|
||||||
// Trigger transcode workflow to take screenshots
|
// Trigger transcode workflow to take screenshots
|
||||||
const task = await prisma.workflowTask.create({
|
const task = await prisma.workflowTask.create({
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { logger } from '@shumai/core/src/logger'
|
|
||||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||||
import { stemFromKey } from '@shumai/core/src/utils/filename'
|
import { stemFromKey } from '@shumai/core/src/utils/filename'
|
||||||
import { prisma, WorkflowTaskStatus, WorkflowTaskType } from '@shumai/db'
|
import { prisma, WorkflowTaskStatus, WorkflowTaskType } from '@shumai/db'
|
||||||
@@ -912,20 +911,6 @@ export class TranscodeService {
|
|||||||
const videoPath = path.join(tmpDir, path.basename(params.assetKey))
|
const videoPath = path.join(tmpDir, path.basename(params.assetKey))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info(
|
|
||||||
{
|
|
||||||
assetId: params.assetId,
|
|
||||||
assetKey: params.assetKey,
|
|
||||||
start: params.start,
|
|
||||||
end: params.end,
|
|
||||||
count: params.count,
|
|
||||||
commentTimestamp: params.commentTimestamp,
|
|
||||||
hasAnnotations: Boolean(params.annotations && params.annotations.length > 0),
|
|
||||||
annotationsCount: params.annotations?.length ?? 0,
|
|
||||||
},
|
|
||||||
'[takeScreenshots] Starting screenshot extraction',
|
|
||||||
)
|
|
||||||
|
|
||||||
// 1. Download video
|
// 1. Download video
|
||||||
await s3Service.downloadToFile(bucket, params.assetKey, videoPath)
|
await s3Service.downloadToFile(bucket, params.assetKey, videoPath)
|
||||||
|
|
||||||
@@ -938,11 +923,6 @@ export class TranscodeService {
|
|||||||
timestamps = Array.from({ length: params.count }, (_, i) => params.start + i * step)
|
timestamps = Array.from({ length: params.count }, (_, i) => params.start + i * step)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(
|
|
||||||
{ initialTimestamps: timestamps, count: params.count },
|
|
||||||
'[takeScreenshots] Generated initial sampling timestamps',
|
|
||||||
)
|
|
||||||
|
|
||||||
// 3. Snap closest timestamp to commentTimestamp if within range (with 100ms tolerance)
|
// 3. Snap closest timestamp to commentTimestamp if within range (with 100ms tolerance)
|
||||||
const commentTimestamp = params.commentTimestamp
|
const commentTimestamp = params.commentTimestamp
|
||||||
const EPSILON = 0.1
|
const EPSILON = 0.1
|
||||||
@@ -959,30 +939,8 @@ export class TranscodeService {
|
|||||||
closestIdx = i
|
closestIdx = i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const oldTs = timestamps[closestIdx]
|
|
||||||
timestamps[closestIdx] = commentTimestamp
|
timestamps[closestIdx] = commentTimestamp
|
||||||
logger.info(
|
|
||||||
{
|
|
||||||
commentTimestamp,
|
|
||||||
snappedIdx: closestIdx,
|
|
||||||
replacedTimestamp: oldTs,
|
|
||||||
newTimestamp: commentTimestamp,
|
|
||||||
resultingTimestamps: timestamps,
|
|
||||||
},
|
|
||||||
'[takeScreenshots] Snapped commentTimestamp to closest timestamp index',
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
logger.warn(
|
|
||||||
{
|
|
||||||
commentTimestamp,
|
|
||||||
start: params.start,
|
|
||||||
end: params.end,
|
|
||||||
},
|
|
||||||
'[takeScreenshots] commentTimestamp is OUT OF RANGE [start, end], skipping snap',
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
logger.info('[takeScreenshots] No commentTimestamp provided')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const results: Array<{ key: string; timestamp: number }> = []
|
const results: Array<{ key: string; timestamp: number }> = []
|
||||||
@@ -1016,10 +974,6 @@ export class TranscodeService {
|
|||||||
|
|
||||||
// 5. Overlay annotations if timestamp matches commentTimestamp (within float tolerance)
|
// 5. Overlay annotations if timestamp matches commentTimestamp (within float tolerance)
|
||||||
if (isMatch && params.annotations && params.annotations.length > 0) {
|
if (isMatch && params.annotations && params.annotations.length > 0) {
|
||||||
logger.info(
|
|
||||||
{ timestamp: t, commentTimestamp, annotationsCount: params.annotations.length },
|
|
||||||
'[takeScreenshots] Overlaying annotations onto frame',
|
|
||||||
)
|
|
||||||
const shotBuffer = fs.readFileSync(localShotPath)
|
const shotBuffer = fs.readFileSync(localShotPath)
|
||||||
const composited = await this.overlayAnnotationsOnBuffer(shotBuffer, params.annotations)
|
const composited = await this.overlayAnnotationsOnBuffer(shotBuffer, params.annotations)
|
||||||
fs.writeFileSync(localShotPath, composited)
|
fs.writeFileSync(localShotPath, composited)
|
||||||
|
|||||||
Reference in New Issue
Block a user