tphim 2.3.1 → 2.3.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/package.json +1 -1
- package/pipeline.mjs +41 -44
package/package.json
CHANGED
package/pipeline.mjs
CHANGED
|
@@ -419,11 +419,10 @@ export async function executePipeline({ input, slug, title, langArg = 'vi' }) {
|
|
|
419
419
|
console.log(`\n⏭ [1/5] File đã có sẵn: ${mp4Path}`);
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
-
//
|
|
423
|
-
const
|
|
424
|
-
const
|
|
425
|
-
const
|
|
426
|
-
const nokia3gpPath = path.join('hls', slug, `${slug}.3gp`);
|
|
422
|
+
// --- STEP 2: PREVIEW SPRITE & STORYBOARD (Fast-Track) ---
|
|
423
|
+
const spriteLowPath = path.join('hls', slug, 'preview_low.jpg');
|
|
424
|
+
const storyboardCheckPath = path.join('hls', slug, 'L1_M0.jpg');
|
|
425
|
+
const outDir = path.join('hls', slug);
|
|
427
426
|
|
|
428
427
|
// Detect VPS environment and optimize
|
|
429
428
|
const vpsOpt = detectVPSOptimization();
|
|
@@ -432,6 +431,41 @@ export async function executePipeline({ input, slug, title, langArg = 'vi' }) {
|
|
|
432
431
|
console.log(` 🚀 Ubuntu VPS Mode: Enabled (preset: ${vpsOpt.preset}, tune: ${vpsOpt.tune})`);
|
|
433
432
|
}
|
|
434
433
|
|
|
434
|
+
console.log('\n📸 [2/5] Capturing Storyboards & Sprites (Turbo Mode)...');
|
|
435
|
+
|
|
436
|
+
// 1. New Storyboard format (L1, L2, L3)
|
|
437
|
+
if (!existsSync(storyboardCheckPath)) {
|
|
438
|
+
try {
|
|
439
|
+
await generateStoryboards(mp4Path, outDir);
|
|
440
|
+
} catch (e) {
|
|
441
|
+
console.log(' ⚠ Storyboard generation failed:', e.message);
|
|
442
|
+
}
|
|
443
|
+
} else {
|
|
444
|
+
console.log(` ⏭ Storyboard levels already exist`);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// 2. Legacy Dual Sprite format
|
|
448
|
+
if (!existsSync(spritePath) || !existsSync(spriteLowPath)) {
|
|
449
|
+
try {
|
|
450
|
+
await generateDualPreviewSprites(mp4Path, outDir);
|
|
451
|
+
} catch (e) {
|
|
452
|
+
console.log(' ⚠ Dual sprite generation failed, falling back to single sprite...');
|
|
453
|
+
const spriteCmd = `"${FFMPEG_BIN}" -i "${mp4Path}" -vf "fps=1/10,scale=160:90,tile=10x10" -q:v 3 "${spritePath}"`;
|
|
454
|
+
try {
|
|
455
|
+
execSync(spriteCmd, { stdio: 'inherit', ...SHELL_OPTS });
|
|
456
|
+
console.log(' ✅ Fallback Preview SpriteSheet ready.');
|
|
457
|
+
} catch (fallbackError) {
|
|
458
|
+
console.log(' ⚠ All sprite generation methods failed.');
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
} else {
|
|
462
|
+
console.log(` ⏭ Dual Preview Sprites already exist`);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// ─── BƯỚC 3: Transcode HLS ────────────────────────────────────
|
|
466
|
+
const masterPath = path.join('hls', slug, masterName);
|
|
467
|
+
const nokia3gpPath = path.join('hls', slug, `${slug}.3gp`);
|
|
468
|
+
|
|
435
469
|
// Danh sách toàn bộ chất lượng hỗ trợ
|
|
436
470
|
const ALL_QUALITIES = [
|
|
437
471
|
{ label: '1080p', w: 1920, h: 1080, bv: '4500k', ba: '192k' },
|
|
@@ -442,15 +476,14 @@ export async function executePipeline({ input, slug, title, langArg = 'vi' }) {
|
|
|
442
476
|
{ label: '144p', w: 256, h: 144, bv: '200k', ba: '48k' }
|
|
443
477
|
];
|
|
444
478
|
|
|
445
|
-
// Lấy ngẫu nhiên từ 4 đến 6 chất lượng
|
|
446
479
|
const count = Math.floor(Math.random() * (Math.min(6, ALL_QUALITIES.length) - 4 + 1)) + 4;
|
|
447
480
|
const selectedQualities = [...ALL_QUALITIES]
|
|
448
481
|
.sort(() => Math.random() - 0.5)
|
|
449
482
|
.slice(0, count)
|
|
450
|
-
.sort((a, b) => b.h - a.h);
|
|
483
|
+
.sort((a, b) => b.h - a.h);
|
|
451
484
|
|
|
452
485
|
if (!existsSync(masterPath)) {
|
|
453
|
-
console.log(`\n📦 [
|
|
486
|
+
console.log(`\n📦 [3/5] Transcoding HLS (${selectedQualities.length} qualities randomized)...`);
|
|
454
487
|
console.log(` ↳ Selected: ${selectedQualities.map(q => q.label).join(', ')}`);
|
|
455
488
|
|
|
456
489
|
const outDir = path.join('hls', slug);
|
|
@@ -506,42 +539,6 @@ export async function executePipeline({ input, slug, title, langArg = 'vi' }) {
|
|
|
506
539
|
console.log(`\n⏭ [2/5] HLS đã có sẵn`);
|
|
507
540
|
}
|
|
508
541
|
|
|
509
|
-
// --- STEP 2.5: PREVIEW SPRITE & STORYBOARD --- (Independent check)
|
|
510
|
-
const spriteLowPath = path.join('hls', slug, 'preview_low.jpg');
|
|
511
|
-
const storyboardCheckPath = path.join('hls', slug, 'L1_M0.jpg');
|
|
512
|
-
|
|
513
|
-
const outDir = path.join('hls', slug);
|
|
514
|
-
|
|
515
|
-
// 1. New Storyboard format (L1, L2, L3)
|
|
516
|
-
if (!existsSync(storyboardCheckPath)) {
|
|
517
|
-
try {
|
|
518
|
-
await generateStoryboards(mp4Path, outDir);
|
|
519
|
-
} catch (e) {
|
|
520
|
-
console.log(' ⚠ Storyboard generation failed:', e.message);
|
|
521
|
-
}
|
|
522
|
-
} else {
|
|
523
|
-
console.log(` ⏭ Storyboard levels already exist`);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
// 2. Legacy Dual Sprite format (for backward compatibility)
|
|
527
|
-
if (!existsSync(spritePath) || !existsSync(spriteLowPath)) {
|
|
528
|
-
try {
|
|
529
|
-
const { highResPath, lowResPath } = await generateDualPreviewSprites(mp4Path, outDir);
|
|
530
|
-
console.log(' ✅ Dual Preview Sprites generated successfully.');
|
|
531
|
-
} catch (e) {
|
|
532
|
-
console.log(' ⚠ Dual sprite generation failed, falling back to single sprite...');
|
|
533
|
-
// Fallback to original method
|
|
534
|
-
const spriteCmd = `"${FFMPEG_BIN}" -i "${mp4Path}" -vf "fps=1/10,scale=160:90,tile=10x10" -q:v 3 "${spritePath}"`;
|
|
535
|
-
try {
|
|
536
|
-
execSync(spriteCmd, { stdio: 'ignore', ...SHELL_OPTS });
|
|
537
|
-
console.log(' ✅ Fallback Preview SpriteSheet ready.');
|
|
538
|
-
} catch (fallbackError) {
|
|
539
|
-
console.log(' ⚠ All sprite generation methods failed.');
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
} else {
|
|
543
|
-
console.log(` ⏭ Dual Preview Sprites already exist`);
|
|
544
|
-
}
|
|
545
542
|
|
|
546
543
|
// ─── BƯỚC 3: Tạo README ───────────────────────────────────────
|
|
547
544
|
console.log('\n📄 [3/5] Generating README.txt...');
|