tphim 1.0.7 → 2.0.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/pipeline.mjs +30 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tphim",
3
- "version": "1.0.7",
3
+ "version": "2.0.0",
4
4
  "description": "TPHIM - Ultimate Video Pipeline: Download, Transcode HLS, AI Subtitles, and Cloud Upload.",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/pipeline.mjs CHANGED
@@ -251,21 +251,27 @@ export async function executePipeline({ input, slug, title, langArg = 'vi' }) {
251
251
  varStreamMapArr.push(`v:${i},a:${i}`);
252
252
  });
253
253
 
254
+ // Generate encoded segment name with timestamp
255
+ const timestamp = Date.now();
256
+ const encodedPrefix = Buffer.from(`txa_${timestamp}`).toString('base64').replace(/[^a-zA-Z0-9]/g, '').substring(0, 8);
257
+
254
258
  const ffmpegCmd = [
255
- `"${FFMPEG_BIN}"`, '-i', `"${mp4Path}"`, '-threads 0',
259
+ `"${FFMPEG_BIN}"`, '-i', `"${mp4Path}"`,
260
+ '-threads 0', '-preset ultrafast', '-tune fastdecode',
256
261
  maps,
257
262
  outputs,
258
263
  '-var_stream_map', `"${varStreamMapArr.join(' ')}"`,
259
264
  '-master_pl_name', `"${masterName}"`,
260
- '-f hls -hls_time 6 -hls_list_size 0',
261
- '-hls_segment_filename', `"${outDir}/%v/seg_%04d.ts"`,
265
+ '-f hls -hls_time 4 -hls_list_size 0 -hls_segment_type mpegts',
266
+ '-hls_segment_filename', `"${outDir}/%v/${encodedPrefix}_%04d.ts"`,
262
267
  `"${outDir}/%v/index.m3u8"`
263
268
  ].join(' ');
264
269
 
265
270
  execSync(ffmpegCmd, { stdio: 'inherit', ...SHELL_OPTS });
266
- console.log(' HLS Master generated.');
271
+ console.log(' HLS Master generated.');
267
272
 
268
273
  // --- BƯỚC 2.1: XUẤT 3GP CHO MÁY CỔ (NOKIA S40/S60) ---
274
+ console.log(' [2.1/5] Exporting 3GP legacy format...');
269
275
  console.log(' 📱 [2.1/5] Exporting 3GP legacy format...');
270
276
  const nokiaCmd = `"${FFMPEG_BIN}" -i "${mp4Path}" -s 320x240 -vcodec mpeg4 -acodec aac -ar 16000 -ac 1 -b:v 250k -b:a 32k -f 3gp "${nokia3gpPath}"`;
271
277
  try {
@@ -320,7 +326,26 @@ export async function executePipeline({ input, slug, title, langArg = 'vi' }) {
320
326
 
321
327
  // ─── BƯỚC 5: Upload Tebi.io ─────────────────────────────────── // --- STEP 5: UPLOAD ---
322
328
  console.log('\n🚀 [5/5] Deploying to Quantum Cloud (Tebi.io)...');
323
- execSync(`node ${path.join(__dirname, 'scripts', 'upload-tebi.mjs')} "${slug}"`, { stdio: 'inherit' });
329
+
330
+ // Optimize upload with parallel processing
331
+ const uploadCmd = `node ${path.join(__dirname, 'scripts', 'upload-tebi.mjs')} "${slug}"`;
332
+
333
+ // Run upload with higher process priority and optimized settings
334
+ try {
335
+ execSync(uploadCmd, {
336
+ stdio: 'inherit',
337
+ cwd: process.cwd(),
338
+ maxBuffer: 1024 * 1024, // Increase buffer size
339
+ env: {
340
+ ...process.env,
341
+ NODE_OPTIONS: '--max-old-space-size=4096', // Optimize Node.js memory
342
+ UV_THREADPOOL_SIZE: '16' // Increase libuv thread pool
343
+ }
344
+ });
345
+ } catch (uploadError) {
346
+ console.error(' ⚠ Upload failed:', uploadError.message);
347
+ throw uploadError;
348
+ }
324
349
 
325
350
  // --- FINAL STEP: GENERATE MASTER README.md ---
326
351
  const finalReadmePath = path.join('hls', slug, 'README.md');