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:
parent
b2da06b4cc
commit
8be9c20124
1 changed files with 16 additions and 3 deletions
|
|
@ -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) => {
|
||||
const args = [
|
||||
'-v', 'error',
|
||||
'-show_entries', 'format=duration',
|
||||
'-of', 'default=noprint_wrappers=1:nokey=1:noinvalidchars=1',
|
||||
'-of', 'default=noprint_wrappers=1:nokey=1',
|
||||
inputPath,
|
||||
];
|
||||
const { stdout } = await runFFmpeg(args);
|
||||
const { stdout } = await runFFprobe(args);
|
||||
return parseFloat(stdout.trim());
|
||||
};
|
||||
|
||||
export const extractFrameAtTime = async (inputPath, outputPath, timeCode) => {
|
||||
const args = [
|
||||
'-i', inputPath,
|
||||
'-ss', timeCode,
|
||||
'-i', inputPath,
|
||||
'-vframes', '1',
|
||||
'-q:v', '2',
|
||||
'-y',
|
||||
outputPath,
|
||||
];
|
||||
await runFFmpeg(args);
|
||||
|
|
@ -55,6 +65,7 @@ export const transcodeVideo = async (inputPath, outputPath, options = {}) => {
|
|||
'-c:a', audioCodec,
|
||||
'-b:a', audioBitrate,
|
||||
'-movflags', '+faststart',
|
||||
'-y',
|
||||
outputPath,
|
||||
];
|
||||
|
||||
|
|
@ -67,6 +78,7 @@ export const trimSegment = async (inputPath, outputPath, inPoint, outPoint) => {
|
|||
'-ss', inPoint,
|
||||
'-to', outPoint,
|
||||
'-c', 'copy',
|
||||
'-y',
|
||||
outputPath,
|
||||
];
|
||||
await runFFmpeg(args);
|
||||
|
|
@ -78,6 +90,7 @@ export const concatSegments = async (segmentListFile, outputPath) => {
|
|||
'-safe', '0',
|
||||
'-i', segmentListFile,
|
||||
'-c', 'copy',
|
||||
'-y',
|
||||
outputPath,
|
||||
];
|
||||
await runFFmpeg(args);
|
||||
|
|
|
|||
Loading…
Reference in a new issue