NapCatQQ source snapshot
This commit is contained in:
commit
f954252a34
1111 files changed
+139867
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import path from 'node:path';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { LogWrapper } from '@/napcat-core/helper/log';
|
||||
import { FFmpegService } from '@/napcat-core/helper/ffmpeg/ffmpeg';
|
||||
|
||||
export async function encodeSilk (filePath: string, temporaryDirectory: string, logger: LogWrapper) {
|
||||
const converted = !(await FFmpegService.isSilk(filePath));
|
||||
const pttPath = converted ? path.join(temporaryDirectory, randomUUID()) : filePath;
|
||||
if (converted) {
|
||||
logger.log(`语音文件${filePath}需要转换成silk`);
|
||||
await FFmpegService.convertToNTSilkTct(filePath, pttPath);
|
||||
}
|
||||
const duration = await FFmpegService.getDuration(pttPath);
|
||||
logger.log('语音文件已就绪:', pttPath, '时长:', duration);
|
||||
return { converted, path: pttPath, duration };
|
||||
}
|
||||
Reference in new issue
Block a user