teqo-backup/tests/fixtures/fake-ffmpeg.mjs
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

31 lines
937 B
JavaScript
Executable file

#!/usr/bin/env node
/**
* C167 test double for ffmpeg: copies the `-i` input to the output path so the
* cut pipeline can run without a real encoder (the developer machine has none).
* `FAKE_FFMPEG_FAIL=1` makes it exit 1; `FAKE_FFMPEG_LOG=<path>` records argv.
* The real binary is exercised by the `skipIf(!hasFfmpeg())` block (CI).
*/
import { copyFileSync, writeFileSync } from 'node:fs'
import { argv, env, exit } from 'node:process'
const args = argv.slice(2)
if (env.FAKE_FFMPEG_LOG) {
writeFileSync(env.FAKE_FFMPEG_LOG, JSON.stringify(args))
}
if (env.FAKE_FFMPEG_FAIL === '1') {
process.stderr.write('fake-ffmpeg: forced failure\n')
exit(1)
}
const inputIndex = args.indexOf('-i')
const input = inputIndex >= 0 ? args[inputIndex + 1] : undefined
const output = args.at(-1)
if (!input || !output) {
process.stderr.write('fake-ffmpeg: missing -i input or output path\n')
exit(2)
}
copyFileSync(input, output)