mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: clone object
This commit is contained in:
@@ -67,7 +67,7 @@ import imageSize from 'image-size';
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async convert(filePath: string, pcmPath: string, logger: LogWrapper): Promise<Buffer> {
|
public static async convert(filePath: string, pcmPath: string): Promise<Buffer> {
|
||||||
const ffmpegInstance = await FFmpeg.create({ core: '@ffmpeg.wasm/core-mt' });
|
const ffmpegInstance = await FFmpeg.create({ core: '@ffmpeg.wasm/core-mt' });
|
||||||
const inputFileName = `${randomUUID()}.input`;
|
const inputFileName = `${randomUUID()}.input`;
|
||||||
const outputFileName = `${randomUUID()}.pcm`;
|
const outputFileName = `${randomUUID()}.pcm`;
|
||||||
@@ -87,12 +87,12 @@ import imageSize from 'image-size';
|
|||||||
try {
|
try {
|
||||||
ffmpegInstance.fs.unlink(outputFileName);
|
ffmpegInstance.fs.unlink(outputFileName);
|
||||||
} catch (unlinkError) {
|
} catch (unlinkError) {
|
||||||
logger.log('Error unlinking output file:', unlinkError);
|
console.error('Error unlinking output file:', unlinkError);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ffmpegInstance.fs.unlink(inputFileName);
|
ffmpegInstance.fs.unlink(inputFileName);
|
||||||
} catch (unlinkError) {
|
} catch (unlinkError) {
|
||||||
logger.log('Error unlinking input file:', unlinkError);
|
console.error('Error unlinking output file:', unlinkError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ export default async function handleFFmpegTask({ method, args }: FFmpegTask): Pr
|
|||||||
case 'convertFile':
|
case 'convertFile':
|
||||||
return await FFmpegService.convertFile(...args as [string, string, string]);
|
return await FFmpegService.convertFile(...args as [string, string, string]);
|
||||||
case 'convert':
|
case 'convert':
|
||||||
return await FFmpegService.convert(...args as [string, string, LogWrapper]);
|
return await FFmpegService.convert(...args as [string, string]);
|
||||||
case 'getVideoInfo':
|
case 'getVideoInfo':
|
||||||
return await FFmpegService.getVideoInfo(...args as [string, string]);
|
return await FFmpegService.getVideoInfo(...args as [string, string]);
|
||||||
default:
|
default:
|
||||||
|
@@ -30,11 +30,11 @@ export class FFmpegService {
|
|||||||
await piscina.destroy();
|
await piscina.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async convert(filePath: string, pcmPath: string, logger: LogWrapper): Promise<Buffer> {
|
public static async convert(filePath: string, pcmPath: string): Promise<Buffer> {
|
||||||
const piscina = new Piscina<EncodeArgs, EncodeResult>({
|
const piscina = new Piscina<EncodeArgs, EncodeResult>({
|
||||||
filename: await getWorkerPath(),
|
filename: await getWorkerPath(),
|
||||||
});
|
});
|
||||||
const result = await piscina.run({ method: 'convert', args: [filePath, pcmPath, logger] });
|
const result = await piscina.run({ method: 'convert', args: [filePath, pcmPath] });
|
||||||
await piscina.destroy();
|
await piscina.destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user