tools_batch_files 1.0.7 → 1.0.8
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/index.js +38 -1
- package/package.json +2 -2
- package/utils/index.js +0 -0
package/index.js
CHANGED
@@ -20,7 +20,8 @@ const watermarkImage = path.join(__dirname, "imgs", "miz-watermark.png");
|
|
20
20
|
const SCREENSHOT_COUNT = 5;
|
21
21
|
const ORIGIN_FILE_DIR = "video";
|
22
22
|
const ZIP_VIDEO_DIR = "zip_video";
|
23
|
-
const
|
23
|
+
const ZIP_VIDEO_DIR_400 = "small_video";
|
24
|
+
const SCREENSHOT_DIR = "screenshots";
|
24
25
|
const ZIP_WATERMARK_VIDEO_DIR = "zip_watermark_video";
|
25
26
|
const ZIP_SCREENSHOT_DIR = "screenshot_watermark";
|
26
27
|
const SOURCE_VIDEO_DIR = "source_video";
|
@@ -166,6 +167,40 @@ const compressVideo = (fileName, outputFileDir, inputFilePath) => {
|
|
166
167
|
});
|
167
168
|
};
|
168
169
|
|
170
|
+
/**
|
171
|
+
* 压缩400p视频
|
172
|
+
*/
|
173
|
+
const compressVideo400p = (fileName, outputFileDir, inputFilePath) => {
|
174
|
+
const outputFilePath = path.join(
|
175
|
+
outputFileDir,
|
176
|
+
ZIP_VIDEO_DIR_400,
|
177
|
+
`zip-${fileName}`
|
178
|
+
);
|
179
|
+
const comand = ffmpeg(inputFilePath);
|
180
|
+
|
181
|
+
ensureDirSync(path.dirname(outputFilePath));
|
182
|
+
return new Promise((resolve, reject) => {
|
183
|
+
comand
|
184
|
+
.videoCodec("libx264")
|
185
|
+
.size("400x?")
|
186
|
+
|
187
|
+
.output(outputFilePath)
|
188
|
+
|
189
|
+
.on("start", () => {
|
190
|
+
logger("400p视频开始压缩……");
|
191
|
+
})
|
192
|
+
.on("end", () => {
|
193
|
+
logger("400p视频压缩完成!");
|
194
|
+
resolve(outputFilePath);
|
195
|
+
})
|
196
|
+
.on("error", (err) => {
|
197
|
+
logger("视频压缩出错:", err);
|
198
|
+
reject(err);
|
199
|
+
})
|
200
|
+
.run();
|
201
|
+
});
|
202
|
+
};
|
203
|
+
|
169
204
|
/**
|
170
205
|
* 生成5张截图
|
171
206
|
*/
|
@@ -336,6 +371,7 @@ const archiveZip = (fileName, inputPath) => {
|
|
336
371
|
SCREENSHOT_DIR,
|
337
372
|
ZIP_WATERMARK_VIDEO_DIR,
|
338
373
|
ZIP_SCREENSHOT_DIR,
|
374
|
+
ZIP_VIDEO_DIR_400
|
339
375
|
];
|
340
376
|
|
341
377
|
directories.forEach((dir) => {
|
@@ -446,6 +482,7 @@ const task = async (row, index) => {
|
|
446
482
|
await fs_asnyc.access(originFilePath, fs_asnyc.constants.F_OK);
|
447
483
|
logFileSize(originFilePath);
|
448
484
|
await compressVideo(fileName, indexFilePath, originFilePath);
|
485
|
+
await compressVideo400p(fileName, indexFilePath, originFilePath);
|
449
486
|
await get5Screenshots(fileName, indexFilePath, originFilePath);
|
450
487
|
await watermarkVideo(fileName, indexFilePath);
|
451
488
|
await watermarkScreenshots(indexFilePath);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "tools_batch_files",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.8",
|
4
4
|
"description": "批处理视频工具",
|
5
5
|
"keywords": [
|
6
6
|
"utils",
|
@@ -10,7 +10,7 @@
|
|
10
10
|
],
|
11
11
|
"main": "index.js",
|
12
12
|
"bin": {
|
13
|
-
"tbf": "
|
13
|
+
"tbf": "index.js"
|
14
14
|
},
|
15
15
|
"scripts": {
|
16
16
|
"test": "echo \"Error: no test specified\" && exit 1",
|
package/utils/index.js
CHANGED
File without changes
|