mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 15:07:40 +00:00
feat(transcode): optimize video operations using ffmpeg http range requests (#393)
* feat(transcode): optimize video operations using ffmpeg http range requests * fix(transcode): preserve non-retryable errors and ensure mapConcurrent settles on rejection
This commit is contained in:
@@ -23,6 +23,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
transcodeVideoActivity,
|
||||
transcodeAudioActivity,
|
||||
transcodeImageActivity,
|
||||
extractPosterActivity,
|
||||
generateSpriteActivity,
|
||||
updateAssetMediaActivity,
|
||||
downloadMediaToTmpActivity,
|
||||
@@ -58,6 +59,23 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
codec: '',
|
||||
}
|
||||
|
||||
if (spec.poster) {
|
||||
const lastSlashIndex = key.lastIndexOf('/')
|
||||
const assetDir = lastSlashIndex === -1 ? '' : key.substring(0, lastSlashIndex)
|
||||
const posterSpec: PrismaJson.PosterInfo = {
|
||||
key: assetDir ? `${assetDir}/poster.webp` : 'poster.webp',
|
||||
}
|
||||
const posterResult = await executeActivity(workerQueue, extractPosterActivity, {
|
||||
assetKey: key,
|
||||
posterSpec,
|
||||
})
|
||||
mediaInfo.poster = posterResult.poster
|
||||
await executeActivity(workerQueue, updateAssetMediaActivity, {
|
||||
assetId: asset.id,
|
||||
mediaInfo,
|
||||
})
|
||||
}
|
||||
|
||||
const metadata = mediaInfo.metadata
|
||||
|
||||
if (mediaInfo.proxyType === 'video' && metadata) {
|
||||
@@ -115,7 +133,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
mediaInfo.thumbnail = thumbTranscode
|
||||
}
|
||||
|
||||
if (spec.sprite || spec.poster) {
|
||||
if (spec.sprite || (spec.poster && !mediaInfo.poster)) {
|
||||
const lastSlashIndex = key.lastIndexOf('/')
|
||||
const assetDir = lastSlashIndex === -1 ? '' : key.substring(0, lastSlashIndex)
|
||||
|
||||
@@ -125,7 +143,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
tileX: 10,
|
||||
tileY: 10,
|
||||
}
|
||||
const posterSpec: PrismaJson.PosterInfo = {
|
||||
const posterSpec: PrismaJson.PosterInfo = mediaInfo.poster || {
|
||||
key: assetDir ? `${assetDir}/poster.webp` : 'poster.webp',
|
||||
}
|
||||
|
||||
@@ -136,8 +154,12 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
posterSpec,
|
||||
mediaInfo,
|
||||
})
|
||||
mediaInfo.sprite = spriteResult.sprite
|
||||
mediaInfo.poster = spriteResult.poster
|
||||
if (spec.sprite) {
|
||||
mediaInfo.sprite = spriteResult.sprite
|
||||
}
|
||||
if (!mediaInfo.poster) {
|
||||
mediaInfo.poster = spriteResult.poster
|
||||
}
|
||||
}
|
||||
|
||||
await executeActivity(workerQueue, updateAssetMediaActivity, {
|
||||
|
||||
Reference in New Issue
Block a user