n8n-nodes-sb-render 1.2.0 → 1.2.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-sb-render",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "n8n community node for video rendering with customizable subtitles, BGM, and narration",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -1,19 +1,89 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Automatically set execute permissions on ffprobe binary after npm install
5
- * This is required for @ffprobe-installer package to work correctly
4
+ * Post-install script for n8n-nodes-sb-render
5
+ *
6
+ * This script:
7
+ * 1. Tries to install system ffmpeg/ffprobe (Docker/Linux only)
8
+ * 2. Sets execute permissions on npm-installed binaries
9
+ * 3. Provides helpful guidance for manual setup
6
10
  */
7
11
 
8
12
  const { chmodSync, existsSync, statSync } = require('fs');
13
+ const { execSync } = require('child_process');
9
14
  const { resolve, join } = require('path');
10
15
  const os = require('os');
11
16
 
12
17
  // Detect current platform
13
18
  const platform = os.platform();
14
19
  const arch = os.arch();
20
+ const isDocker = existsSync('/.dockerenv') || existsSync('/run/.containerenv');
15
21
 
16
22
  console.log(`šŸ” Platform detected: ${platform}-${arch}`);
23
+ if (isDocker) {
24
+ console.log('🐳 Docker/Container environment detected');
25
+ }
26
+
27
+ /**
28
+ * Try to install system ffmpeg (Docker/Linux only)
29
+ * Returns true if successful or already installed
30
+ */
31
+ function tryInstallSystemFFmpeg() {
32
+ if (platform !== 'linux' || process.getuid?.() !== 0) {
33
+ return false; // Only try on Linux as root
34
+ }
35
+
36
+ try {
37
+ // Check if already installed
38
+ execSync('which ffmpeg', { stdio: 'ignore' });
39
+ console.log('āœ… System ffmpeg already installed');
40
+ return true;
41
+ } catch {
42
+ // Not installed, try to install
43
+ console.log('šŸ“¦ Attempting to install system ffmpeg...');
44
+
45
+ try {
46
+ // Detect package manager and install
47
+ if (existsSync('/usr/bin/apk')) {
48
+ // Alpine (n8n official Docker image)
49
+ execSync('apk add --no-cache ffmpeg', { stdio: 'inherit' });
50
+ console.log('āœ… Installed ffmpeg via apk (Alpine)');
51
+ return true;
52
+ } else if (existsSync('/usr/bin/apt-get')) {
53
+ // Debian/Ubuntu
54
+ execSync('apt-get update && apt-get install -y ffmpeg', { stdio: 'inherit' });
55
+ console.log('āœ… Installed ffmpeg via apt-get (Debian/Ubuntu)');
56
+ return true;
57
+ } else if (existsSync('/usr/bin/yum')) {
58
+ // RedHat/CentOS
59
+ execSync('yum install -y ffmpeg', { stdio: 'inherit' });
60
+ console.log('āœ… Installed ffmpeg via yum (RedHat/CentOS)');
61
+ return true;
62
+ }
63
+ } catch (installError) {
64
+ console.warn('āš ļø Could not auto-install ffmpeg:', installError.message);
65
+ return false;
66
+ }
67
+ }
68
+
69
+ return false;
70
+ }
71
+
72
+ // Try to install system ffmpeg in Docker environments
73
+ if (isDocker && platform === 'linux') {
74
+ console.log('\nšŸš€ Auto-install attempt (Docker environment)...');
75
+ const installed = tryInstallSystemFFmpeg();
76
+
77
+ if (installed) {
78
+ console.log('✨ System ffmpeg is ready! No additional setup needed.');
79
+ console.log(' sb-render will automatically use system binaries.\n');
80
+ } else {
81
+ console.log('ā„¹ļø Auto-install not available (requires root or manual setup)');
82
+ console.log(' Falling back to npm packages with permission fix...\n');
83
+ }
84
+ }
85
+
86
+ console.log(`šŸ”§ Setting up npm ffmpeg/ffprobe binaries...`);
17
87
 
18
88
  // Platform-specific binary paths
19
89
  const getPlatformPath = () => {
@@ -89,26 +159,51 @@ for (const ffprobePath of possiblePaths) {
89
159
  }
90
160
 
91
161
  // Summary and recommendations
92
- console.log('\nšŸ“‹ Summary:');
93
- if (successCount === 0 && errorCount === 0) {
94
- console.warn('āš ļø No ffprobe binaries found. This is normal if @ffprobe-installer is not yet installed.');
95
- console.warn('\nšŸ’” If you encounter "EACCES" or "ENOENT" errors when running SB Render:');
96
- console.warn(' 1. Ensure @ffprobe-installer is installed: npm ls @ffprobe-installer');
97
- console.warn(' 2. For Linux/Docker: chmod +x node_modules/@ffprobe-installer/*/ffprobe');
98
- console.warn(' 3. For n8n Cloud: Consider using system ffprobe instead');
162
+ console.log('\nšŸ“‹ Post-install Summary:');
163
+
164
+ // Check if system ffmpeg is available
165
+ let hasSystemFFmpeg = false;
166
+ try {
167
+ execSync('which ffmpeg', { stdio: 'ignore' });
168
+ hasSystemFFmpeg = true;
169
+ } catch {
170
+ hasSystemFFmpeg = false;
171
+ }
172
+
173
+ if (hasSystemFFmpeg) {
174
+ console.log('šŸŽ‰ Setup Complete - Ready to use!');
175
+ console.log(' āœ… System ffmpeg/ffprobe detected');
176
+ console.log(' āœ… sb-render will use system binaries (best option)');
177
+ console.log(' āœ… No additional configuration needed\n');
99
178
  } else if (successCount > 0) {
100
- console.log(`āœ… Successfully processed ${successCount} ffprobe binary(ies)`);
101
-
102
- if (process.env.NODE_ENV === 'production' || process.env.N8N_CONFIG_FILES) {
103
- console.log('\n🐳 Docker/n8n environment detected. Additional tips:');
104
- console.log(' - Ensure container has execute permissions on /tmp and node_modules');
105
- console.log(' - Consider adding ffmpeg/ffprobe to your Docker image');
106
- console.log(' - For n8n Cloud: System-level ffprobe may be required');
179
+ console.log('āœ… Setup Complete - npm binaries ready');
180
+ console.log(` āœ… Fixed permissions on ${successCount} binary(ies)`);
181
+ console.log(' āš ļø Using npm binaries (fallback option)');
182
+ console.log('\nšŸ’” For better performance in Docker/n8n:');
183
+ console.log(' Install system ffmpeg: docker exec <container> apk add ffmpeg');
184
+ console.log(' OR: docker exec <container> apt-get install -y ffmpeg\n');
185
+ } else if (successCount === 0 && errorCount === 0) {
186
+ console.warn('āš ļø No ffmpeg binaries found');
187
+ console.warn(' This is normal if optional dependencies failed to install.');
188
+ console.warn('\nšŸ“¦ Recommended setup for your environment:');
189
+
190
+ if (isDocker || platform === 'linux') {
191
+ console.warn(' 1. Install system ffmpeg (recommended):');
192
+ console.warn(' • Alpine: apk add ffmpeg');
193
+ console.warn(' • Debian/Ubuntu: apt-get install -y ffmpeg');
194
+ console.warn(' • RedHat/CentOS: yum install -y ffmpeg');
195
+ } else {
196
+ console.warn(' 1. Install system ffmpeg:');
197
+ console.warn(' • macOS: brew install ffmpeg');
198
+ console.warn(' • Windows: choco install ffmpeg');
107
199
  }
200
+ console.warn(' 2. OR reinstall with: npm install --include=optional\n');
108
201
  } else {
109
- console.error('āŒ Failed to set permissions on any ffprobe binaries');
110
- console.error('\nšŸ”§ Manual fix options:');
111
- console.error(' 1. chmod +x node_modules/@ffprobe-installer/*/ffprobe');
112
- console.error(' 2. Install system ffmpeg: apt-get install ffmpeg (Linux)');
113
- console.error(' 3. Use Docker with proper --privileged or volume mounts');
202
+ console.error('āŒ Permission fix failed');
203
+ console.error('\nšŸ”§ Manual setup required:');
204
+ console.error(' Option 1 (Recommended): Install system ffmpeg');
205
+ console.error(' Option 2: chmod +x node_modules/@ffprobe-installer/*/ffprobe');
206
+ console.error(' Option 3: Use Docker with proper permissions\n');
114
207
  }
208
+
209
+ console.log('šŸ“š Documentation: https://github.com/choisb87/sb-render#prerequisites');