mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 06:54:28 +00:00
fix(video): transcribe from the smallest full proxy
This commit is contained in:
@@ -86,6 +86,7 @@ export const assetInfoSchema = z.object({
|
||||
type: z.string(),
|
||||
targetType: z.string().optional().nullable(),
|
||||
status: z.string(),
|
||||
mediaType: z.string().nullable().optional(),
|
||||
proxyType: z.enum(['image', 'video', 'audio', 'pdf', '3d']).nullable().optional(),
|
||||
latestChildren: z.array(childPreviewSchema).optional(),
|
||||
preview: previewInfoSchema.nullable().optional(),
|
||||
|
||||
@@ -26,8 +26,35 @@ export const transcriptLanguagesSchema = z.object({
|
||||
languages: z.array(z.object({ code: transcriptLanguageCodeSchema, name: z.string().min(1) })),
|
||||
})
|
||||
|
||||
interface TranscriptVideoProxy {
|
||||
key?: string
|
||||
resolution?: string
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
|
||||
export function selectTranscriptVideoProxyKey(
|
||||
media?: { videoTranscodes?: TranscriptVideoProxy[]; videoPreview?: { key?: string } } | null,
|
||||
): string | undefined {
|
||||
let selectedKey: string | undefined
|
||||
let smallestArea = Infinity
|
||||
for (const proxy of media?.videoTranscodes ?? []) {
|
||||
if (!proxy.key || proxy.key === media?.videoPreview?.key || proxy.resolution === '180p') {
|
||||
continue
|
||||
}
|
||||
|
||||
const area = proxy.width > 0 && proxy.height > 0 ? proxy.width * proxy.height : Infinity
|
||||
if (area < smallestArea) {
|
||||
selectedKey = proxy.key
|
||||
smallestArea = area
|
||||
}
|
||||
}
|
||||
return selectedKey
|
||||
}
|
||||
|
||||
export const transcriptionErrors = {
|
||||
noAudio: 'The video does not contain an audio track',
|
||||
noProxy: 'A completed full video proxy is required to generate transcripts',
|
||||
tooLarge: 'Audio exceeds the embedding server upload limit',
|
||||
} as const
|
||||
|
||||
|
||||
Reference in New Issue
Block a user