MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / runFfmpegTransform

Method runFfmpegTransform

rev/rev.ts:428–454  ·  view source on GitHub ↗
(options: TransformOptions)

Source from the content-addressed store, hash-verified

426 }
427
428 // ==================== FFmpeg 转换 ====================
429
430 private async runFfmpegTransform(options: TransformOptions): Promise<void> {
431 const { inputPath, outputPath, flipMode, invertColors, isGif, isWebm } =
432 options;
433
434 const filters = this.buildVideoFilters(flipMode, invertColors);
435 const args = this.buildFfmpegArgs(
436 inputPath,
437 outputPath,
438 filters,
439 isGif,
440 isWebm
441 );
442
443 try {
444 await execFileAsync('ffmpeg', args);
445 } catch (error: any) {
446 if (error?.code === 'ENOENT') {
447 throw new Error('未找到 ffmpeg,请先安装后再试');
448 }
449 const stderr =
450 typeof error?.stderr === 'string' ? error.stderr.trim() : '';
451 if (stderr) {
452 throw new Error(`ffmpeg 处理失败: ${stderr.split('\n')[0]}`);
453 }
454 throw new Error(`ffmpeg 处理失败: ${error?.message || String(error)}`);
455 }
456 }
457

Callers 1

transformMediaMethod · 0.95

Calls 3

buildVideoFiltersMethod · 0.95
buildFfmpegArgsMethod · 0.95
execFileAsyncFunction · 0.85

Tested by

no test coverage detected