mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-03 14:34:40 +00:00
fix(video): transcribe from the smallest full proxy
This commit is contained in:
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user