tphim 1.0.6 → 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 (3) hide show
  1. package/README.md +56 -4
  2. package/package.json +1 -1
  3. package/pipeline.mjs +30 -5
package/README.md CHANGED
@@ -23,18 +23,55 @@ sudo apt-get install -y nodejs
23
23
  ### 2. Cài đặt FFmpeg & Python
24
24
  ```bash
25
25
  sudo apt update
26
- sudo apt install -y ffmpeg python3 python3-pip
26
+ sudo apt install -y ffmpeg python3 python3-pip python3-full python3-venv
27
27
  ```
28
28
 
29
29
  ### 3. Cài đặt yt-dlp (Để tải video)
30
30
  ```bash
31
+ # Method 1: Download trực tiếp (Recommended)
31
32
  sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp
32
33
  sudo chmod a+rx /usr/local/bin/yt-dlp
34
+
35
+ # Method 2: Sử dụng pipx (không cần venv)
36
+ sudo apt install pipx
37
+ pipx install yt-dlp
38
+ pipx ensurepath
39
+
40
+ # Method 3: Sử dụng virtual environment
41
+ python3 -m venv ~/.yt-dlp-env
42
+ source ~/.yt-dlp-env/bin/activate
43
+ pip install yt-dlp
44
+ deactivate
45
+ echo 'export PATH="$HOME/.yt-dlp-env/bin:$PATH"' >> ~/.bashrc
46
+ source ~/.bashrc
33
47
  ```
34
48
 
35
49
  ### 4. Cài đặt thư viện AI (faster-whisper)
36
50
  ```bash
37
- pip3 install faster-whisper
51
+ # Tạo virtual environment cho AI
52
+ python3 -m venv ~/.whisper-env
53
+ source ~/.whisper-env/bin/activate
54
+ pip install faster-whisper
55
+ deactivate
56
+ echo 'export PATH="$HOME/.whisper-env/bin:$PATH"' >> ~/.bashrc
57
+ source ~/.bashrc
58
+ ```
59
+
60
+ ### 5. Cài đặt TPHIM
61
+ ```bash
62
+ npm install -g tphim
63
+ ```
64
+
65
+ ### 6. Kiểm tra cài đặt
66
+ ```bash
67
+ # Kiểm tra yt-dlp
68
+ yt-dlp --version
69
+
70
+ # Kiểm tra TPHIM CLI
71
+ ntxa help
72
+
73
+ # Kiểm tra FFmpeg
74
+ ffmpeg -version
38
75
  ```
39
76
 
40
77
  ---
@@ -48,12 +85,27 @@ Bạn hoàn toàn có thể chạy Pipeline này ngay trên điện thoại:
48
85
  pkg update && pkg upgrade
49
86
  pkg install nodejs ffmpeg python python-pip wget
50
87
  ```
51
- 2. **Cài đặt yt-dlp:**(không nhất thiết phải cài)
88
+
89
+ 2. **Cài đặt yt-dlp:**
52
90
  ```bash
91
+ # Method 1: Download trực tiếp
92
+ wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O $PREFIX/bin/yt-dlp
93
+ chmod a+rx $PREFIX/bin/yt-dlp
94
+
95
+ # Method 2: Sử dụng pip
53
96
  pip install yt-dlp
54
97
  ```
98
+
55
99
  3. **Cài đặt thư viện AI:**
56
- (Lưu ý: faster-whisper trên Termux có thể cần cấu hình thêm tùy dòng máy Android).
100
+ ```bash
101
+ # Termux thường không cần venv, install trực tiếp
102
+ pip install faster-whisper
103
+ ```
104
+
105
+ 4. **Cài đặt TPHIM:**
106
+ ```bash
107
+ npm install -g tphim
108
+ ```
57
109
 
58
110
  ---
59
111
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tphim",
3
- "version": "1.0.6",
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');