feat(transcode): update preview thumbnail resolution to 300p with max length constraint (#281)

* feat(transcode): update preview thumbnail resolution to 300p with max length constraint

* fix(transcode): address code review feedback on preview thumbnail transcoding
This commit is contained in:
Yiling-J
2026-08-08 15:17:51 +08:00
committed by GitHub
parent c91867b8eb
commit ee4933a4f8
10 changed files with 179 additions and 24 deletions
@@ -377,6 +377,10 @@ export async function transcodeImageActivity(
outputFile,
params.imageSpec.width,
params.imageSpec.quality,
{
height: params.imageSpec.height || null,
isPreview: params.imageSpec.isPreview ?? false,
},
)
const buffer = fs.readFileSync(outputFile)
await s3Service.putObject(bucket, key, buffer, buffer.length, 'image/webp')
@@ -115,8 +115,8 @@ describe('transcodeImageWorkflow', () => {
mockActivities.transcodeImageActivity.mockResolvedValue({
key: 't.webp',
width: 480,
height: 480,
width: 300,
height: 300,
format: 'webp',
})
@@ -132,8 +132,8 @@ describe('transcodeImageWorkflow', () => {
mediaInfo: expect.objectContaining({
thumbnail: expect.objectContaining({
key: 't.webp',
width: 480,
height: 480,
width: 300,
height: 300,
}),
}),
})
@@ -75,7 +75,7 @@ export async function transcodeImageWorkflow(task: WorkflowTask): Promise<void>
const thumbTranscode = await executeActivity(workerQueue, transcodeImageActivity, {
assetKey: key,
filePath,
imageSpec: { width: 480, height: 0, quality: 80, format: 'webp' },
imageSpec: { width: 300, height: 300, quality: 80, format: 'webp', isPreview: true },
})
mediaInfo.thumbnail = thumbTranscode
}
@@ -124,8 +124,8 @@ describe('transcodeVideoWorkflow', () => {
})
mockActivities.transcodeImageActivity.mockResolvedValue({
key: 't.webp',
width: 480,
height: 270,
width: 300,
height: 300,
})
await transcodeVideoWorkflow(task)
@@ -108,7 +108,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
const thumbTranscode = await executeActivity(workerQueue, transcodeImageActivity, {
assetKey: key,
filePath,
imageSpec: { width: 480, height: 0, quality: 80, format: 'webp' },
imageSpec: { width: 300, height: 300, quality: 80, format: 'webp', isPreview: true },
})
mediaInfo.thumbnail = thumbTranscode
}