fix(video): transcribe from the smallest full proxy

This commit is contained in:
yiling
2026-12-03 21:05:40 +08:00
parent cdd45429c4
commit 659ed5dab4
15 changed files with 210 additions and 53 deletions
@@ -13,7 +13,7 @@ import {
import { transcriptService } from '@shumai/core/src/transcript/transcript'
import { selectPrimaryAudioStream } from '@shumai/core/src/transcode/transcode'
import { prisma } from '@shumai/db'
import { transcriptionErrors } from '@shumai/dtos'
import { selectTranscriptVideoProxyKey, transcriptionErrors } from '@shumai/dtos'
import {
ApplicationFailure,
defineStep,
@@ -69,21 +69,18 @@ export const extractTranscriptAudioActivity = defineStep(
status: 'processed',
isDeleted: false,
mediaType: { startsWith: 'video/' },
storageKey: { status: 'active', isArchived: false },
},
select: { storageKey: { select: { key: true } } },
select: { media: true },
})
if (!asset?.storageKey) {
throw ApplicationFailure.create({
message: 'Video is no longer available',
nonRetryable: true,
})
const proxyKey = selectTranscriptVideoProxyKey(asset?.media)
if (!proxyKey) {
throw ApplicationFailure.create({ message: transcriptionErrors.noProxy, nonRetryable: true })
}
const signal = getLocalTaskAbortSignal(taskId)
const directory = await mkdtemp(join(tmpdir(), 'shumai-transcript-'))
try {
const video = await ensureLocalMediaFile(asset.storageKey.key, join(directory, 'video'))
const video = await ensureLocalMediaFile(proxyKey, join(directory, 'video.mp4'))
const { stdout } = await execFileAsync(
'ffprobe',
['-v', 'error', '-select_streams', 'a', '-show_streams', '-of', 'json', video],