@zwa73/utils 1.0.202 → 1.0.203
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +7 -4
- package/compile.bat +0 -2
- package/dist/UtilFfmpegTools.d.ts +0 -86
- package/dist/UtilFfmpegTools.js +0 -291
- package/input.wav +0 -0
- package/jest.config.js +0 -16
- package/scripts/compile.ps1 +0 -6
- package/scripts/expand-macro.ps1 +0 -2
- package/scripts/postinstall.js +0 -61
- package/scripts/release.ps1 +0 -3
- package/scripts/watch.ps1 +0 -10
- package/src/QuickExport.ts +0 -70
- package/src/UtilClass.ts +0 -259
- package/src/UtilCodecs.ts +0 -102
- package/src/UtilCom.macro.ts +0 -28
- package/src/UtilCom.ts +0 -456
- package/src/UtilCom_bak.txt +0 -345
- package/src/UtilDecorators.ts +0 -223
- package/src/UtilFP.macro.ts +0 -29
- package/src/UtilFP.ts +0 -222
- package/src/UtilFfmpegTools.ts +0 -320
- package/src/UtilFileTools.ts +0 -410
- package/src/UtilFunctions.ts +0 -938
- package/src/UtilI18n.ts +0 -278
- package/src/UtilInterfaces.ts +0 -264
- package/src/UtilLogger.ts +0 -390
- package/src/UtilSymbol.ts +0 -45
- package/src/backup.txt +0 -102
- package/src/index.ts +0 -13
- package/test.bat +0 -2
- package/watch.bat +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -20,7 +20,6 @@ __exportStar(require("./UtilSymbol"), exports);
|
|
|
20
20
|
__exportStar(require("./UtilClass"), exports);
|
|
21
21
|
__exportStar(require("./UtilCom"), exports);
|
|
22
22
|
__exportStar(require("./UtilCodecs"), exports);
|
|
23
|
-
__exportStar(require("./UtilFfmpegTools"), exports);
|
|
24
23
|
__exportStar(require("./UtilDecorators"), exports);
|
|
25
24
|
__exportStar(require("./UtilFileTools"), exports);
|
|
26
25
|
__exportStar(require("./UtilLogger"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zwa73/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.203",
|
|
4
4
|
"description": "my utils",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@deepkit/type": "^1.0.1-alpha.153",
|
|
20
|
-
"fluent-ffmpeg": "2.1.2",
|
|
21
20
|
"form-data": "^4.0.2",
|
|
22
21
|
"glob": "^10.4.1",
|
|
23
22
|
"handlebars": "^4.7.8",
|
|
@@ -33,7 +32,6 @@
|
|
|
33
32
|
"winston-daily-rotate-file": "^4.7.1"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
|
-
"@types/fluent-ffmpeg": "^2.1.21",
|
|
37
35
|
"@types/jest": "^29.5.12",
|
|
38
36
|
"@types/node": "^20.14.11",
|
|
39
37
|
"@zwa73/dev-utils": "*",
|
|
@@ -41,5 +39,10 @@
|
|
|
41
39
|
"ts-jest": "^29.1.2",
|
|
42
40
|
"tsc-alias": "^1.8.8",
|
|
43
41
|
"typescript": "^5.3.3"
|
|
44
|
-
}
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"index.js",
|
|
46
|
+
"index.d.ts"
|
|
47
|
+
]
|
|
45
48
|
}
|
package/compile.bat
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { FfprobeData } from "fluent-ffmpeg";
|
|
2
|
-
/**输入输出路径映射
|
|
3
|
-
* 输入路径:输入路径
|
|
4
|
-
*/
|
|
5
|
-
export type IOMap = {
|
|
6
|
-
[key: string]: string;
|
|
7
|
-
};
|
|
8
|
-
/**ffmpeg工具类
|
|
9
|
-
*/
|
|
10
|
-
declare class SFfmpegTool {
|
|
11
|
-
/**静态构造函数 */
|
|
12
|
-
static init(): void;
|
|
13
|
-
/**设置ffmpeg路径 */
|
|
14
|
-
static setFfmpegPath(ffmpegPath: string): void;
|
|
15
|
-
/**获取音频文件的元数据
|
|
16
|
-
* @param inputWavPath - 输入音频文件路径
|
|
17
|
-
* @returns 返回音频文件的元数据
|
|
18
|
-
*/
|
|
19
|
-
static getAudioMetaData(inputWavPath: string): Promise<FfprobeData | null>;
|
|
20
|
-
/**flac转ogg
|
|
21
|
-
* @param inputFlacFile - 输入flac文件路径
|
|
22
|
-
* @param outputOggPath - 输出ogg文件路径
|
|
23
|
-
* @param quality - 质量
|
|
24
|
-
*/
|
|
25
|
-
static flac2ogg(inputFlacFile: string, outputOggPath: string, quality?: number): Promise<boolean>;
|
|
26
|
-
/**flac转wav
|
|
27
|
-
* @param inputFlacFile - 输入flac文件路径
|
|
28
|
-
* @param outputWavPath - 输出wav文件路径
|
|
29
|
-
*/
|
|
30
|
-
static flac2wav(inputFlacFile: string, outputWavPath: string): Promise<boolean>;
|
|
31
|
-
/**wav转ogg
|
|
32
|
-
* @param inputWavPath - 输入wav文件路径
|
|
33
|
-
* @param outputOggPath - 输出ogg文件路径
|
|
34
|
-
* @param quality - 质量
|
|
35
|
-
*/
|
|
36
|
-
static wav2ogg(inputWavPath: string, outputOggPath: string, quality?: number): Promise<boolean>;
|
|
37
|
-
/**剪切音频
|
|
38
|
-
* @param audioPath - 输入音频文件路径
|
|
39
|
-
* @param outPath - 输出音频文件路径
|
|
40
|
-
* @param start - 开始时间
|
|
41
|
-
* @param time - 时长
|
|
42
|
-
*/
|
|
43
|
-
static cutAudio(audioPath: string, outPath: string, start: number, time: number): Promise<boolean>;
|
|
44
|
-
/**删除首尾静音
|
|
45
|
-
* @param inputWavPath - 输入wav文件路径
|
|
46
|
-
* @param outputWavPath - 输出wav文件路径
|
|
47
|
-
* @param threshold - 静音阈值/dB
|
|
48
|
-
* @param silence - 保留静音时长
|
|
49
|
-
*/
|
|
50
|
-
static trimSilence(inputWavPath: string, outputWavPath: string, threshold?: number, silence?: number): Promise<boolean>;
|
|
51
|
-
/**重采样
|
|
52
|
-
* @param inputWavPath - 输入wav文件路径
|
|
53
|
-
* @param outputWavPath - 输出wav文件路径
|
|
54
|
-
*/
|
|
55
|
-
static resample(inputWavPath: string, outputWavPath: string, rate?: number): Promise<boolean>;
|
|
56
|
-
/**检查WAV文件是否为单声道
|
|
57
|
-
* @param filePath - 要检查的WAV文件路径
|
|
58
|
-
*/
|
|
59
|
-
static isMono(filePath: string): Promise<boolean>;
|
|
60
|
-
/**wav转ogg多线程
|
|
61
|
-
* @param ioMap - 输入输出路径映射
|
|
62
|
-
* @param quality - 质量
|
|
63
|
-
* @param cpCount - 并发数
|
|
64
|
-
*/
|
|
65
|
-
static wav2oggMP(ioMap: IOMap, quality?: number, cpCount?: number): Promise<void>;
|
|
66
|
-
/**flac转ogg多线程
|
|
67
|
-
* @param ioMap - 输入输出路径映射
|
|
68
|
-
* @param quality - 质量
|
|
69
|
-
* @param cpCount - 并发数
|
|
70
|
-
*/
|
|
71
|
-
static flac2oggMP(ioMap: IOMap, quality?: number, cpCount?: number): Promise<void>;
|
|
72
|
-
/**删除静音多线程
|
|
73
|
-
* @param ioMap - 输入输出路径映射
|
|
74
|
-
* @param threshold - 静音阈值/dB
|
|
75
|
-
* @param silence - 保留静音时长
|
|
76
|
-
*/
|
|
77
|
-
static trimSilenceMP(ioMap: IOMap, threshold?: number, silence?: number, cpCount?: number): Promise<void>;
|
|
78
|
-
/**重采样多线程
|
|
79
|
-
* @param ioMap - 输入输出路径映射
|
|
80
|
-
* @param rate - 采样率
|
|
81
|
-
* @param cpCount - 并发数
|
|
82
|
-
*/
|
|
83
|
-
static resampleMP(ioMap: IOMap, rate?: number, cpCount?: number): Promise<void>;
|
|
84
|
-
}
|
|
85
|
-
export default SFfmpegTool;
|
|
86
|
-
export { SFfmpegTool };
|
package/dist/UtilFfmpegTools.js
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.SFfmpegTool = void 0;
|
|
30
|
-
const fluent_ffmpeg_1 = __importDefault(require("fluent-ffmpeg"));
|
|
31
|
-
const pathe_1 = __importDefault(require("pathe"));
|
|
32
|
-
const fs = __importStar(require("fs"));
|
|
33
|
-
const UtilLogger_1 = require("./UtilLogger");
|
|
34
|
-
const UtilClass_1 = require("./UtilClass");
|
|
35
|
-
const QuickExport_1 = require("./QuickExport");
|
|
36
|
-
/**ffmpeg工具类
|
|
37
|
-
*/
|
|
38
|
-
class SFfmpegTool {
|
|
39
|
-
/**静态构造函数 */
|
|
40
|
-
static init() {
|
|
41
|
-
const ffmpegPath = process?.env?.FFMPEG_PATH;
|
|
42
|
-
if (ffmpegPath != null) {
|
|
43
|
-
const exepath = pathe_1.default.join(ffmpegPath, "ffmpeg.exe");
|
|
44
|
-
SFfmpegTool.setFfmpegPath(exepath);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**设置ffmpeg路径 */
|
|
48
|
-
static setFfmpegPath(ffmpegPath) {
|
|
49
|
-
fluent_ffmpeg_1.default.setFfmpegPath(ffmpegPath);
|
|
50
|
-
}
|
|
51
|
-
/**获取音频文件的元数据
|
|
52
|
-
* @param inputWavPath - 输入音频文件路径
|
|
53
|
-
* @returns 返回音频文件的元数据
|
|
54
|
-
*/
|
|
55
|
-
static async getAudioMetaData(inputWavPath) {
|
|
56
|
-
return new Promise((resolve, reject) => {
|
|
57
|
-
fluent_ffmpeg_1.default.ffprobe(inputWavPath, function (err, metadata) {
|
|
58
|
-
if (err) {
|
|
59
|
-
UtilLogger_1.SLogger.error("SFfmpegTool.getAudioMetaData 错误", err);
|
|
60
|
-
resolve(null);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
resolve(metadata);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
/**flac转ogg
|
|
69
|
-
* @param inputFlacFile - 输入flac文件路径
|
|
70
|
-
* @param outputOggPath - 输出ogg文件路径
|
|
71
|
-
* @param quality - 质量
|
|
72
|
-
*/
|
|
73
|
-
static async flac2ogg(inputFlacFile, outputOggPath, quality = 10) {
|
|
74
|
-
const wavPath = pathe_1.default.join(pathe_1.default.dirname(inputFlacFile), `tmp_${pathe_1.default.basename(inputFlacFile, ".flac")}.wav`);
|
|
75
|
-
await SFfmpegTool.flac2wav(inputFlacFile, wavPath);
|
|
76
|
-
await SFfmpegTool.wav2ogg(wavPath, outputOggPath, quality);
|
|
77
|
-
await fs.promises.unlink(wavPath);
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
/**flac转wav
|
|
81
|
-
* @param inputFlacFile - 输入flac文件路径
|
|
82
|
-
* @param outputWavPath - 输出wav文件路径
|
|
83
|
-
*/
|
|
84
|
-
static async flac2wav(inputFlacFile, outputWavPath) {
|
|
85
|
-
await new Promise((resolve, reject) => {
|
|
86
|
-
const ins = (0, fluent_ffmpeg_1.default)(inputFlacFile)
|
|
87
|
-
.audioCodec("pcm_s16le")
|
|
88
|
-
.save(outputWavPath)
|
|
89
|
-
.on("end", () => {
|
|
90
|
-
resolve(true);
|
|
91
|
-
ins.kill('SIGTERM');
|
|
92
|
-
})
|
|
93
|
-
.on("error", (err) => {
|
|
94
|
-
reject(err);
|
|
95
|
-
ins.kill('SIGTERM');
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
/**wav转ogg
|
|
101
|
-
* @param inputWavPath - 输入wav文件路径
|
|
102
|
-
* @param outputOggPath - 输出ogg文件路径
|
|
103
|
-
* @param quality - 质量
|
|
104
|
-
*/
|
|
105
|
-
static async wav2ogg(inputWavPath, outputOggPath, quality = 10) {
|
|
106
|
-
//.audioQuality(10)
|
|
107
|
-
//.audioBitrate("192k")
|
|
108
|
-
//.audioChannels(channels)
|
|
109
|
-
//.noMetadata()
|
|
110
|
-
return new Promise((resolve, reject) => {
|
|
111
|
-
const ins = (0, fluent_ffmpeg_1.default)(inputWavPath)
|
|
112
|
-
.audioQuality(quality)
|
|
113
|
-
.audioCodec("libvorbis")
|
|
114
|
-
.save(outputOggPath)
|
|
115
|
-
.on("end", () => {
|
|
116
|
-
resolve(true);
|
|
117
|
-
ins.kill('SIGTERM');
|
|
118
|
-
})
|
|
119
|
-
.on("error", (err) => {
|
|
120
|
-
reject(err);
|
|
121
|
-
ins.kill('SIGTERM');
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**剪切音频
|
|
126
|
-
* @param audioPath - 输入音频文件路径
|
|
127
|
-
* @param outPath - 输出音频文件路径
|
|
128
|
-
* @param start - 开始时间
|
|
129
|
-
* @param time - 时长
|
|
130
|
-
*/
|
|
131
|
-
static async cutAudio(audioPath, outPath, start, time) {
|
|
132
|
-
return new Promise((resolve, reject) => {
|
|
133
|
-
const ins = (0, fluent_ffmpeg_1.default)(audioPath)
|
|
134
|
-
.setStartTime(start)
|
|
135
|
-
.setDuration(time)
|
|
136
|
-
.save(outPath)
|
|
137
|
-
.on("end", () => {
|
|
138
|
-
resolve(true);
|
|
139
|
-
ins.kill('SIGTERM');
|
|
140
|
-
})
|
|
141
|
-
.on("error", (err) => {
|
|
142
|
-
reject(err);
|
|
143
|
-
ins.kill('SIGTERM');
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
/**删除首尾静音
|
|
148
|
-
* @param inputWavPath - 输入wav文件路径
|
|
149
|
-
* @param outputWavPath - 输出wav文件路径
|
|
150
|
-
* @param threshold - 静音阈值/dB
|
|
151
|
-
* @param silence - 保留静音时长
|
|
152
|
-
*/
|
|
153
|
-
static async trimSilence(inputWavPath, outputWavPath, threshold = -50, silence = 0.1) {
|
|
154
|
-
return new Promise((resolve, reject) => {
|
|
155
|
-
const ins = (0, fluent_ffmpeg_1.default)(inputWavPath)
|
|
156
|
-
.audioFilters(`silenceremove=start_periods=1:start_threshold=${threshold}dB:start_silence=${silence}:detection=peak`)
|
|
157
|
-
.audioFilters("areverse")
|
|
158
|
-
.audioFilters(`silenceremove=start_periods=1:start_threshold=${threshold}dB:start_silence=${silence}:detection=peak`)
|
|
159
|
-
.audioFilters("areverse")
|
|
160
|
-
.save(outputWavPath)
|
|
161
|
-
.on("end", () => {
|
|
162
|
-
resolve(true);
|
|
163
|
-
ins.kill('SIGTERM');
|
|
164
|
-
})
|
|
165
|
-
.on("error", (err) => {
|
|
166
|
-
reject(err);
|
|
167
|
-
ins.kill('SIGTERM');
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/**重采样
|
|
172
|
-
* @param inputWavPath - 输入wav文件路径
|
|
173
|
-
* @param outputWavPath - 输出wav文件路径
|
|
174
|
-
*/
|
|
175
|
-
static async resample(inputWavPath, outputWavPath, rate = 22050) {
|
|
176
|
-
return new Promise((resolve, reject) => {
|
|
177
|
-
const ins = (0, fluent_ffmpeg_1.default)(inputWavPath)
|
|
178
|
-
.audioFrequency(rate)
|
|
179
|
-
.save(outputWavPath)
|
|
180
|
-
.on("end", () => {
|
|
181
|
-
resolve(true);
|
|
182
|
-
ins.kill('SIGTERM');
|
|
183
|
-
})
|
|
184
|
-
.on("error", (err) => {
|
|
185
|
-
reject(err);
|
|
186
|
-
ins.kill('SIGTERM');
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
/**检查WAV文件是否为单声道
|
|
191
|
-
* @param filePath - 要检查的WAV文件路径
|
|
192
|
-
*/
|
|
193
|
-
static async isMono(filePath) {
|
|
194
|
-
const metadata = await SFfmpegTool.getAudioMetaData(filePath);
|
|
195
|
-
if (metadata == null)
|
|
196
|
-
(0, QuickExport_1.throwError)("SFfmpegTool.isMono 获取音频元数据失败");
|
|
197
|
-
// 检查音频流的声道数
|
|
198
|
-
const audioStream = metadata.streams.find(stream => stream.codec_type === 'audio');
|
|
199
|
-
if (audioStream == null)
|
|
200
|
-
(0, QuickExport_1.throwError)("SFfmpegTool.isMono 未找到音频流");
|
|
201
|
-
return audioStream.channels === 1;
|
|
202
|
-
}
|
|
203
|
-
//多线程处理
|
|
204
|
-
/**wav转ogg多线程
|
|
205
|
-
* @param ioMap - 输入输出路径映射
|
|
206
|
-
* @param quality - 质量
|
|
207
|
-
* @param cpCount - 并发数
|
|
208
|
-
*/
|
|
209
|
-
static async wav2oggMP(ioMap, quality = 10, cpCount = 16) {
|
|
210
|
-
await UtilClass_1.Stream.from(Object.entries(ioMap))
|
|
211
|
-
.concurrent(cpCount)
|
|
212
|
-
.map(async ([inPath, outPath]) => {
|
|
213
|
-
UtilLogger_1.SLogger.info(`SFfmpegTool.wav2oggMP 正在处理:${outPath}`);
|
|
214
|
-
await SFfmpegTool.wav2ogg(inPath, outPath, quality);
|
|
215
|
-
})
|
|
216
|
-
.append();
|
|
217
|
-
}
|
|
218
|
-
/**flac转ogg多线程
|
|
219
|
-
* @param ioMap - 输入输出路径映射
|
|
220
|
-
* @param quality - 质量
|
|
221
|
-
* @param cpCount - 并发数
|
|
222
|
-
*/
|
|
223
|
-
static async flac2oggMP(ioMap, quality = 10, cpCount = 16) {
|
|
224
|
-
await UtilClass_1.Stream.from(Object.entries(ioMap))
|
|
225
|
-
.concurrent(cpCount)
|
|
226
|
-
.map(async ([inPath, outPath]) => {
|
|
227
|
-
UtilLogger_1.SLogger.info(`SFfmpegTool.flac2oggMP 正在处理:${outPath}`);
|
|
228
|
-
await SFfmpegTool.flac2ogg(inPath, outPath, quality);
|
|
229
|
-
})
|
|
230
|
-
.append();
|
|
231
|
-
}
|
|
232
|
-
/**删除静音多线程
|
|
233
|
-
* @param ioMap - 输入输出路径映射
|
|
234
|
-
* @param threshold - 静音阈值/dB
|
|
235
|
-
* @param silence - 保留静音时长
|
|
236
|
-
*/
|
|
237
|
-
static async trimSilenceMP(ioMap, threshold = -50, silence = 0.1, cpCount = 16) {
|
|
238
|
-
await UtilClass_1.Stream.from(Object.entries(ioMap))
|
|
239
|
-
.concurrent(cpCount)
|
|
240
|
-
.map(async ([inPath, outPath]) => {
|
|
241
|
-
UtilLogger_1.SLogger.info(`SFfmpegTool.trimSilenceMP 正在处理:${outPath}`);
|
|
242
|
-
await SFfmpegTool.trimSilence(inPath, outPath, threshold, silence);
|
|
243
|
-
})
|
|
244
|
-
.append();
|
|
245
|
-
}
|
|
246
|
-
/**重采样多线程
|
|
247
|
-
* @param ioMap - 输入输出路径映射
|
|
248
|
-
* @param rate - 采样率
|
|
249
|
-
* @param cpCount - 并发数
|
|
250
|
-
*/
|
|
251
|
-
static async resampleMP(ioMap, rate = 22050, cpCount = 16) {
|
|
252
|
-
await UtilClass_1.Stream.from(Object.entries(ioMap))
|
|
253
|
-
.concurrent(cpCount)
|
|
254
|
-
.map(async ([inPath, outPath]) => {
|
|
255
|
-
UtilLogger_1.SLogger.info(`SFfmpegTool.resampleMP 正在处理:${outPath}`);
|
|
256
|
-
await SFfmpegTool.resample(inPath, outPath, rate);
|
|
257
|
-
})
|
|
258
|
-
.append();
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
exports.SFfmpegTool = SFfmpegTool;
|
|
262
|
-
SFfmpegTool.init();
|
|
263
|
-
/**多线程任务分割器
|
|
264
|
-
* @param iomap - 输入输出路径映射
|
|
265
|
-
* @param cpCount - 并发数
|
|
266
|
-
*/
|
|
267
|
-
function MPClip(iomap, cpCount = 16) {
|
|
268
|
-
let cpList = [];
|
|
269
|
-
for (let i = 0; i < cpCount; i++)
|
|
270
|
-
cpList.push({});
|
|
271
|
-
let cpCounter = 0;
|
|
272
|
-
for (let key in iomap) {
|
|
273
|
-
let cpIndex = cpCounter % cpCount;
|
|
274
|
-
cpCounter++;
|
|
275
|
-
cpList[cpIndex][key] = iomap[key];
|
|
276
|
-
}
|
|
277
|
-
return cpList;
|
|
278
|
-
}
|
|
279
|
-
/**ffmpeg流
|
|
280
|
-
*/
|
|
281
|
-
class SFfmpegStream {
|
|
282
|
-
iomap;
|
|
283
|
-
cmdList = [];
|
|
284
|
-
constructor(iomap) {
|
|
285
|
-
this.iomap = iomap;
|
|
286
|
-
}
|
|
287
|
-
async save() { }
|
|
288
|
-
//执行函数
|
|
289
|
-
async cmdAreverse() { }
|
|
290
|
-
}
|
|
291
|
-
exports.default = SFfmpegTool;
|
package/input.wav
DELETED
|
Binary file
|
package/jest.config.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
roots: ['./jest'],
|
|
7
|
-
transform: {
|
|
8
|
-
'^.+\\.tsx?$': 'ts-jest',
|
|
9
|
-
},
|
|
10
|
-
moduleNameMapper: {
|
|
11
|
-
'^@src/(.*)$': '<rootDir>/dist/$1',
|
|
12
|
-
'^@/(.*)$': '<rootDir>/$1',
|
|
13
|
-
'^@$': '<rootDir>/index'
|
|
14
|
-
},
|
|
15
|
-
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
|
16
|
-
};
|
package/scripts/compile.ps1
DELETED
package/scripts/expand-macro.ps1
DELETED
package/scripts/postinstall.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const { UtilFT } = require("../index");
|
|
3
|
-
|
|
4
|
-
const PACKAGE_PATH = path.join(__dirname,'..','package.json');
|
|
5
|
-
const VERSION_PATH = path.join(__dirname,"..","..","version.json");
|
|
6
|
-
//提示表
|
|
7
|
-
const INFO_TABLE = {
|
|
8
|
-
"1.0.47":"UtilFT.fileSearch 函数与返回值发生变动, 请使用fileSearchRegex 或 fileSearchGlob",
|
|
9
|
-
"1.0.104":
|
|
10
|
-
"UtilFT.fleSearchGlob 更改参数 floder作为第一个参数 ingore 移入 可选参数对象 \n" +
|
|
11
|
-
"UtilFT.fleSearchRegex 添加了一个可选参数 \n" +
|
|
12
|
-
"UtilFT.createPath 更改参数 dir 移入 可选参数对象 \n" +
|
|
13
|
-
"UtilFT.createPathSync 更改参数 dir 移入 可选参数对象 \n" +
|
|
14
|
-
"UtilFT.ensurePathExists 更改参数 dir 移入 可选参数对象 \n" +
|
|
15
|
-
"UtilFT.ensurePathExistsSync 更改参数 dir 移入 可选参数对象 \n",
|
|
16
|
-
"1.0.128":"fileSearch 添加Sync版本, 默认改为异步函数",
|
|
17
|
-
"1.0.131":"repeatPromise 与 repeatPost 改为传入可选参数表模式",
|
|
18
|
-
}
|
|
19
|
-
const PKG_NAME = "utils";
|
|
20
|
-
|
|
21
|
-
// 将版本号转换为可以比较的数字
|
|
22
|
-
function versionToNumber(version) {
|
|
23
|
-
if(version==undefined) return 0;
|
|
24
|
-
return version.split('.').map(Number).reduce((acc, val) => acc * 1000 + val);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
//显示提示
|
|
28
|
-
function showUpgradeMessages(prevVersion, currentVersion) {
|
|
29
|
-
const prevVersionNumber = versionToNumber(prevVersion);
|
|
30
|
-
const currentVersionNumber = versionToNumber(currentVersion);
|
|
31
|
-
let hasOut = false;
|
|
32
|
-
// 遍历infoTable中的所有版本
|
|
33
|
-
for (const version in INFO_TABLE) {
|
|
34
|
-
const versionNumber = versionToNumber(version);
|
|
35
|
-
// 如果用户的上一个版本低于这个版本,而当前版本高于或等于这个版本
|
|
36
|
-
if (versionNumber > prevVersionNumber && versionNumber <= currentVersionNumber) {
|
|
37
|
-
// 显示这个版本的提示信息
|
|
38
|
-
log(INFO_TABLE[version]);
|
|
39
|
-
hasOut=true;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return hasOut;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const log = ()=>undefined;
|
|
46
|
-
|
|
47
|
-
async function main(){
|
|
48
|
-
const packageTable = await UtilFT.loadJSONFile(PACKAGE_PATH);
|
|
49
|
-
const currentVersion = packageTable.version;
|
|
50
|
-
await UtilFT.ensurePathExists(VERSION_PATH);
|
|
51
|
-
const versionTable = await UtilFT.loadJSONFile(VERSION_PATH,{default:{}});
|
|
52
|
-
const prevVersion = versionTable[PKG_NAME]?.version ?? "10000.0.0";
|
|
53
|
-
|
|
54
|
-
log(`${currentVersion} 版本已安装`);
|
|
55
|
-
|
|
56
|
-
const hasOut = showUpgradeMessages(prevVersion, currentVersion);
|
|
57
|
-
|
|
58
|
-
const ntable = Object.assign({},versionTable,{[PKG_NAME]:{version:currentVersion}});
|
|
59
|
-
await UtilFT.writeJSONFile(VERSION_PATH, ntable);
|
|
60
|
-
}
|
|
61
|
-
main()
|
package/scripts/release.ps1
DELETED
package/scripts/watch.ps1
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# 定义一个函数来运行脚本
|
|
2
|
-
function New-Script {
|
|
3
|
-
param($command)
|
|
4
|
-
# 在后台运行命令
|
|
5
|
-
Start-Process -NoNewWindow -FilePath "powershell" -ArgumentList "-Command", $command
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
# 开始运行脚本
|
|
9
|
-
New-Script "tsc -w -p tsconfig.compile.json"
|
|
10
|
-
New-Script "tsc-alias -w -p tsconfig.compile.json"
|
package/src/QuickExport.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { UtilFT } from "./UtilFileTools";
|
|
2
|
-
import { UtilFunc } from "./UtilFunctions";
|
|
3
|
-
import { Outcome } from "./UtilInterfaces";
|
|
4
|
-
import { Failed, None, NoneOut, Success } from "./UtilSymbol";
|
|
5
|
-
|
|
6
|
-
export const {
|
|
7
|
-
outcome,
|
|
8
|
-
matchProc,
|
|
9
|
-
sucesProc,
|
|
10
|
-
isFailed,
|
|
11
|
-
isSafeNumber,
|
|
12
|
-
isSuccess,
|
|
13
|
-
likeNone,
|
|
14
|
-
expect,
|
|
15
|
-
assertType,
|
|
16
|
-
assertLiteral,
|
|
17
|
-
deepClone,
|
|
18
|
-
sleep,
|
|
19
|
-
stringifyJToken,
|
|
20
|
-
getTime,
|
|
21
|
-
mapEntries,
|
|
22
|
-
dedent,
|
|
23
|
-
throwError,
|
|
24
|
-
eitherize,
|
|
25
|
-
taskEitherize,
|
|
26
|
-
memoize,
|
|
27
|
-
ivk,l2s,s2l,
|
|
28
|
-
} = UtilFunc;
|
|
29
|
-
|
|
30
|
-
export const {
|
|
31
|
-
stylizePath ,
|
|
32
|
-
posixizePath ,
|
|
33
|
-
win32izePath ,
|
|
34
|
-
currosizePath,
|
|
35
|
-
} = UtilFT;
|
|
36
|
-
|
|
37
|
-
if(false){
|
|
38
|
-
let aaser = assertLiteral({a:1})
|
|
39
|
-
|
|
40
|
-
let a:"asd"|"dsa" = null as any;
|
|
41
|
-
const r = matchProc(a,{
|
|
42
|
-
"asd":(a)=>"ssa" as const,
|
|
43
|
-
"dsa":(b)=>"ssb" as const,
|
|
44
|
-
})
|
|
45
|
-
let b:Outcome<"a","123">|NoneOut = null as any;
|
|
46
|
-
const r1 = matchProc(b,{
|
|
47
|
-
"a":(a,s)=>"ssa" as const,
|
|
48
|
-
[None]:(b,s)=>"ssb" as const,
|
|
49
|
-
})
|
|
50
|
-
let udt = outcome("ssa","None");
|
|
51
|
-
|
|
52
|
-
type test = Outcome<"a"|"b",any> extends Outcome<"a",12>|Outcome<"b",34>
|
|
53
|
-
? "suc" : "fal"
|
|
54
|
-
let assa = isFailed(null as any as Failed)
|
|
55
|
-
let assb = isFailed(null as any as Failed|Success)
|
|
56
|
-
let assc = isFailed(null as any as Success)
|
|
57
|
-
let asssc = isFailed(null)
|
|
58
|
-
let assa1 = isFailed(null as any as Outcome<Failed,unknown>)
|
|
59
|
-
let assb1 = isFailed(null as any as Outcome<Failed|Success,unknown>)
|
|
60
|
-
let assc1 = isFailed(null as any as Outcome<Success,unknown>)
|
|
61
|
-
|
|
62
|
-
let proct = sucesProc(null as any as Outcome<Failed|Success,"123">|Outcome<Failed,"1234">|Outcome<Success,"1s23">,
|
|
63
|
-
(s)=>"ssa" as const,
|
|
64
|
-
(f)=>"ssad" as const,
|
|
65
|
-
()=>123 as const)
|
|
66
|
-
|
|
67
|
-
let matt = matchProc(null as any as Outcome<symbol,123>,{
|
|
68
|
-
|
|
69
|
-
})
|
|
70
|
-
}
|