teqo-backup/src/utilities/speech/speechCutScheduler.ts
Francisco Solla 352801853f feat(C167): corta o trecho [início,fim] do acervo e publica o arquivo numa página compartilhável
Seleção do C166 ganha "Cortar vídeo": título/descrição por IA (editáveis, com fallback determinístico), job assíncrono com ffmpeg por re-encode exato e polling dos quatro passos, e página pública unlisted /corte/<id> (noindex, OG, crédito CC BY) servindo o mesmo MP4. Collection speechCut com access canReadSpeechCut (advisor/leader negados) e kill switch por status; ffmpeg entra só no runner da imagem com FFMPEG_PATH para teste.
2026-09-15 10:24:36 -03:00

20 lines
682 B
TypeScript

import 'server-only'
import config from '@payload-config'
import { after } from 'next/server'
import { getPayload } from 'payload'
import { runSpeechCutJob } from '@/utilities/speech/speechCutJob'
/**
* C167 — starts the cut after the create/retry response has been sent
* (`after` from `next/server`), so the POST never waits on the Câmara download
* or ffmpeg. Kept apart from the job so `speechCutJob` stays importable in a
* plain Node test without the request lifecycle.
*/
export const startSpeechCutJobInBackground = (cutId: number): void => {
after(async () => {
const payload = await getPayload({ config })
await runSpeechCutJob(payload, cutId)
})
}