@boruto_vk7/stickengine 4.2.0 → 4.2.2
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/README.md +1 -1
- package/dist/cjs/StickEngine.js +18 -5
- package/dist/esm/StickEngine.js +18 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @boruto_vk7/stickengine
|
|
2
2
|
|
|
3
|
-
> **4.2.
|
|
3
|
+
> **4.2.2 — TURBO**: WebP animado agora é codificado **em paralelo** (um processo ffmpeg por núcleo, até 4) e os pedaços são remontados byte a byte, sem recodificar a junção. Defaults de velocidade: `fps` 15→12, `quality` animado 80→75, `compressionLevel` 6→1 (6 multiplicava o tempo de encode), auto-shrink proporcional (≤3 tentativas) e ffmpeg do sistema preferido quando tem `libwebp`. Um clipe de 4s que levava ~20s numa VPS fraca agora sai em poucos segundos. Desative o paralelismo com `parallelChunks: 1`.
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
[](https://www.npmjs.com/package/@boruto_vk7/stickengine)
|
package/dist/cjs/StickEngine.js
CHANGED
|
@@ -1277,8 +1277,19 @@ class StickEngine extends node_events_1.EventEmitter {
|
|
|
1277
1277
|
k = Math.round(Number(opt) || 0);
|
|
1278
1278
|
}
|
|
1279
1279
|
else {
|
|
1280
|
-
|
|
1281
|
-
|
|
1280
|
+
// calibração por ambiente: Docker/VPS com cota de CPU (os.cpus() vê
|
|
1281
|
+
// os núcleos do host e superestima em planos com cota pequena)
|
|
1282
|
+
const env = parseInt(String(process.env.STICKENGINE_PARALLEL_CHUNKS || ''), 10);
|
|
1283
|
+
if (Number.isFinite(env) && env >= 1) {
|
|
1284
|
+
k = env;
|
|
1285
|
+
}
|
|
1286
|
+
else {
|
|
1287
|
+
// availableParallelism respeita a cota de CPU do container
|
|
1288
|
+
const cores = typeof node_os_1.default.availableParallelism === 'function'
|
|
1289
|
+
? node_os_1.default.availableParallelism()
|
|
1290
|
+
: node_os_1.default.cpus().length;
|
|
1291
|
+
k = Math.min(4, Math.max(1, Math.ceil(cores * 0.75)));
|
|
1292
|
+
}
|
|
1282
1293
|
}
|
|
1283
1294
|
k = Math.max(1, Math.min(8, k));
|
|
1284
1295
|
if (totalFrames < 24)
|
|
@@ -1298,7 +1309,7 @@ class StickEngine extends node_events_1.EventEmitter {
|
|
|
1298
1309
|
opts.push('-i', input);
|
|
1299
1310
|
const vf = this.buildAnimatedFilters(crop, String(this.options.fit || 'cover'), fps);
|
|
1300
1311
|
opts.push('-vf', vf);
|
|
1301
|
-
opts.push('-frames:v', String(frames), '-c:v', 'libwebp', '-preset', 'default', '-an', '-loop', '0', '-
|
|
1312
|
+
opts.push('-frames:v', String(frames), '-c:v', 'libwebp', '-preset', 'default', '-an', '-loop', '0', '-lossless', '0', '-compression_level', String(this.compressionLevelFor(isAnimated)), '-q:v', String(q), '-quality', String(q), '-y', output);
|
|
1302
1313
|
node_child_process_1.execFile(ffmpegPath || 'ffmpeg', opts, { timeout: 120000, maxBuffer: 16 * 1024 * 1024 }, (err, _so, se) => {
|
|
1303
1314
|
if (err) {
|
|
1304
1315
|
const detalhe = se ? ' — ' + String(se).split('\n').filter(Boolean).slice(-2).join(' ') : '';
|
|
@@ -1339,9 +1350,10 @@ class StickEngine extends node_events_1.EventEmitter {
|
|
|
1339
1350
|
contagens.push(base + (resto-- > 0 ? 1 : 0));
|
|
1340
1351
|
const arquivos = [];
|
|
1341
1352
|
const promessas = [];
|
|
1342
|
-
let t =
|
|
1353
|
+
let t = this.startTime > 0 ? this.startTime : 0;
|
|
1343
1354
|
for (let i = 0; i < k; i++) {
|
|
1344
|
-
|
|
1355
|
+
// extensão .webp obrigatória: o muxer do ffmpeg é escolhido pela extensão
|
|
1356
|
+
const arq = output.replace(/\.webp$/i, '') + '.p' + i + '.webp';
|
|
1345
1357
|
arquivos.push(arq);
|
|
1346
1358
|
promessas.push(this.runEncodeChunk(input, arq, t, contagens[i], true, quality, fps, crop));
|
|
1347
1359
|
t += contagens[i] / fps;
|
|
@@ -1359,6 +1371,7 @@ class StickEngine extends node_events_1.EventEmitter {
|
|
|
1359
1371
|
catch { /* ignore */ }
|
|
1360
1372
|
}
|
|
1361
1373
|
}
|
|
1374
|
+
this.say('info', 'ENCODE', `#· webp animado em ${k} pedaços paralelos (${total} frames)`);
|
|
1362
1375
|
return true;
|
|
1363
1376
|
}
|
|
1364
1377
|
catch (e) {
|
package/dist/esm/StickEngine.js
CHANGED
|
@@ -1262,8 +1262,19 @@ export class StickEngine extends EventEmitter {
|
|
|
1262
1262
|
k = Math.round(Number(opt) || 0);
|
|
1263
1263
|
}
|
|
1264
1264
|
else {
|
|
1265
|
-
|
|
1266
|
-
|
|
1265
|
+
// calibração por ambiente: Docker/VPS com cota de CPU (os.cpus() vê
|
|
1266
|
+
// os núcleos do host e superestima em planos com cota pequena)
|
|
1267
|
+
const env = parseInt(String(process.env.STICKENGINE_PARALLEL_CHUNKS || ''), 10);
|
|
1268
|
+
if (Number.isFinite(env) && env >= 1) {
|
|
1269
|
+
k = env;
|
|
1270
|
+
}
|
|
1271
|
+
else {
|
|
1272
|
+
// availableParallelism respeita a cota de CPU do container
|
|
1273
|
+
const cores = typeof os.availableParallelism === 'function'
|
|
1274
|
+
? os.availableParallelism()
|
|
1275
|
+
: os.cpus().length;
|
|
1276
|
+
k = Math.min(4, Math.max(1, Math.ceil(cores * 0.75)));
|
|
1277
|
+
}
|
|
1267
1278
|
}
|
|
1268
1279
|
k = Math.max(1, Math.min(8, k));
|
|
1269
1280
|
if (totalFrames < 24)
|
|
@@ -1283,7 +1294,7 @@ export class StickEngine extends EventEmitter {
|
|
|
1283
1294
|
opts.push('-i', input);
|
|
1284
1295
|
const vf = this.buildAnimatedFilters(crop, String(this.options.fit || 'cover'), fps);
|
|
1285
1296
|
opts.push('-vf', vf);
|
|
1286
|
-
opts.push('-frames:v', String(frames), '-c:v', 'libwebp', '-preset', 'default', '-an', '-loop', '0', '-
|
|
1297
|
+
opts.push('-frames:v', String(frames), '-c:v', 'libwebp', '-preset', 'default', '-an', '-loop', '0', '-lossless', '0', '-compression_level', String(this.compressionLevelFor(isAnimated)), '-q:v', String(q), '-quality', String(q), '-y', output);
|
|
1287
1298
|
execFile(ffmpegPath || 'ffmpeg', opts, { timeout: 120000, maxBuffer: 16 * 1024 * 1024 }, (err, _so, se) => {
|
|
1288
1299
|
if (err) {
|
|
1289
1300
|
const detalhe = se ? ' — ' + String(se).split('\n').filter(Boolean).slice(-2).join(' ') : '';
|
|
@@ -1324,9 +1335,10 @@ export class StickEngine extends EventEmitter {
|
|
|
1324
1335
|
contagens.push(base + (resto-- > 0 ? 1 : 0));
|
|
1325
1336
|
const arquivos = [];
|
|
1326
1337
|
const promessas = [];
|
|
1327
|
-
let t =
|
|
1338
|
+
let t = this.startTime > 0 ? this.startTime : 0;
|
|
1328
1339
|
for (let i = 0; i < k; i++) {
|
|
1329
|
-
|
|
1340
|
+
// extensão .webp obrigatória: o muxer do ffmpeg é escolhido pela extensão
|
|
1341
|
+
const arq = output.replace(/\.webp$/i, '') + '.p' + i + '.webp';
|
|
1330
1342
|
arquivos.push(arq);
|
|
1331
1343
|
promessas.push(this.runEncodeChunk(input, arq, t, contagens[i], true, quality, fps, crop));
|
|
1332
1344
|
t += contagens[i] / fps;
|
|
@@ -1344,6 +1356,7 @@ export class StickEngine extends EventEmitter {
|
|
|
1344
1356
|
catch { /* ignore */ }
|
|
1345
1357
|
}
|
|
1346
1358
|
}
|
|
1359
|
+
this.say('info', 'ENCODE', `#· webp animado em ${k} pedaços paralelos (${total} frames)`);
|
|
1347
1360
|
return true;
|
|
1348
1361
|
}
|
|
1349
1362
|
catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boruto_vk7/stickengine",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "WhatsApp sticker engine - media preparation only: 512x512 static/animated WebP, parallel animated encoding, automatic black-border removal, full-bleed cover fit, audio sticker pair (WebP + OGG/Opus), bundled canvas and ffmpeg binaries, pack EXIF, chalk logging. No message sending, no Baileys coupling.",
|
|
5
5
|
"author": "Borutovk7 - Lagos Solutions",
|
|
6
6
|
"license": "MIT",
|