fix(infra+workers): S3 creds, ffprobe, BullMQ awaits, thumbnail seek, bin optional, docker-compose vars, jobs Redis, recorders stop codes: executor.js

This commit is contained in:
Zac Gaetano 2026-05-16 00:29:49 -04:00
parent b2da06b4cc
commit 8be9c20124

View file

@ -16,23 +16,33 @@ export const runFFmpeg = async (args, options = {}) => {
} }
}; };
const runFFprobe = async (args) => {
try {
const { stdout } = await execFileAsync('ffprobe', args);
return { stdout };
} catch (error) {
throw new Error(`FFprobe error: ${error.message}\nStderr: ${error.stderr}`);
}
};
export const getMediaDuration = async (inputPath) => { export const getMediaDuration = async (inputPath) => {
const args = [ const args = [
'-v', 'error', '-v', 'error',
'-show_entries', 'format=duration', '-show_entries', 'format=duration',
'-of', 'default=noprint_wrappers=1:nokey=1:noinvalidchars=1', '-of', 'default=noprint_wrappers=1:nokey=1',
inputPath, inputPath,
]; ];
const { stdout } = await runFFmpeg(args); const { stdout } = await runFFprobe(args);
return parseFloat(stdout.trim()); return parseFloat(stdout.trim());
}; };
export const extractFrameAtTime = async (inputPath, outputPath, timeCode) => { export const extractFrameAtTime = async (inputPath, outputPath, timeCode) => {
const args = [ const args = [
'-i', inputPath,
'-ss', timeCode, '-ss', timeCode,
'-i', inputPath,
'-vframes', '1', '-vframes', '1',
'-q:v', '2', '-q:v', '2',
'-y',
outputPath, outputPath,
]; ];
await runFFmpeg(args); await runFFmpeg(args);
@ -55,6 +65,7 @@ export const transcodeVideo = async (inputPath, outputPath, options = {}) => {
'-c:a', audioCodec, '-c:a', audioCodec,
'-b:a', audioBitrate, '-b:a', audioBitrate,
'-movflags', '+faststart', '-movflags', '+faststart',
'-y',
outputPath, outputPath,
]; ];
@ -67,6 +78,7 @@ export const trimSegment = async (inputPath, outputPath, inPoint, outPoint) => {
'-ss', inPoint, '-ss', inPoint,
'-to', outPoint, '-to', outPoint,
'-c', 'copy', '-c', 'copy',
'-y',
outputPath, outputPath,
]; ];
await runFFmpeg(args); await runFFmpeg(args);
@ -78,6 +90,7 @@ export const concatSegments = async (segmentListFile, outputPath) => {
'-safe', '0', '-safe', '0',
'-i', segmentListFile, '-i', segmentListFile,
'-c', 'copy', '-c', 'copy',
'-y',
outputPath, outputPath,
]; ];
await runFFmpeg(args); await runFFmpeg(args);