/* eslint-disable @typescript-eslint/no-explicit-any */ import { VideoInfo } from './video'; import path from 'path'; import { fileURLToPath } from 'url'; import { runTask } from './worker'; type EncodeArgs = { method: 'extractThumbnail' | 'convertFile' | 'convert' | 'getVideoInfo'; args: any[]; }; type EncodeResult = any; function getWorkerPath() { return path.join(path.dirname(fileURLToPath(import.meta.url)), './ffmpeg-worker.mjs'); } export class FFmpegService { public static async extractThumbnail(videoPath: string, thumbnailPath: string): Promise { await runTask(getWorkerPath(), { method: 'extractThumbnail', args: [videoPath, thumbnailPath] }); } public static async convertFile(inputFile: string, outputFile: string, format: string): Promise { await runTask(getWorkerPath(), { method: 'convertFile', args: [inputFile, outputFile, format] }); } public static async convert(filePath: string, pcmPath: string): Promise { const result = await runTask(getWorkerPath(), { method: 'convert', args: [filePath, pcmPath] }); return result; } public static async getVideoInfo(videoPath: string, thumbnailPath: string): Promise { const result = await await runTask(getWorkerPath(), { method: 'getVideoInfo', args: [videoPath, thumbnailPath] }); return result; } }