@lee-jisoo/n8n-nodes-mediafx 1.6.3 → 1.6.5
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.
|
@@ -93,7 +93,10 @@ function isASSFile(filePath) {
|
|
|
93
93
|
* Build force_style string for subtitles filter
|
|
94
94
|
*/
|
|
95
95
|
function buildForceStyle(fontName, fontSize, primaryColor, outlineColor, outlineWidth, backColor, enableBackground, alignment, marginV) {
|
|
96
|
-
|
|
96
|
+
// BorderStyle: 1=outline+shadow, 3=opaque box, 4=translucent box (limited support)
|
|
97
|
+
// For background box, use BorderStyle=3 with BackColour
|
|
98
|
+
const borderStyle = enableBackground ? 3 : 1;
|
|
99
|
+
const shadow = enableBackground ? 4 : 0; // Add shadow for box effect
|
|
97
100
|
const styleParams = [
|
|
98
101
|
`FontName=${fontName}`,
|
|
99
102
|
`FontSize=${fontSize}`,
|
|
@@ -103,8 +106,8 @@ function buildForceStyle(fontName, fontSize, primaryColor, outlineColor, outline
|
|
|
103
106
|
`Bold=0`,
|
|
104
107
|
`Italic=0`,
|
|
105
108
|
`BorderStyle=${borderStyle}`,
|
|
106
|
-
`Outline=${outlineWidth}`,
|
|
107
|
-
`Shadow
|
|
109
|
+
`Outline=${enableBackground ? 0 : outlineWidth}`,
|
|
110
|
+
`Shadow=${shadow}`,
|
|
108
111
|
`Alignment=${alignment}`,
|
|
109
112
|
`MarginV=${marginV}`,
|
|
110
113
|
];
|
|
@@ -132,13 +135,31 @@ async function executeAddSubtitle(video, subtitleFile, style, itemIndex) {
|
|
|
132
135
|
const positionType = style.positionType || 'alignment';
|
|
133
136
|
let horizontalAlign = 'center';
|
|
134
137
|
let verticalAlign = 'bottom';
|
|
135
|
-
let
|
|
138
|
+
let paddingY = 20;
|
|
136
139
|
if (positionType === 'alignment') {
|
|
137
140
|
horizontalAlign = style.horizontalAlign || 'center';
|
|
138
141
|
verticalAlign = style.verticalAlign || 'bottom';
|
|
139
|
-
|
|
142
|
+
paddingY = (_d = style.paddingY) !== null && _d !== void 0 ? _d : 20;
|
|
140
143
|
}
|
|
141
144
|
const alignment = getASSAlignment(horizontalAlign, verticalAlign);
|
|
145
|
+
// Calculate MarginV based on vertical alignment
|
|
146
|
+
// For SRT files, middle alignment (4,5,6) doesn't work reliably with force_style
|
|
147
|
+
// So we use bottom alignment (2) with large MarginV to simulate middle position
|
|
148
|
+
let marginV = paddingY;
|
|
149
|
+
let effectiveAlignment = alignment;
|
|
150
|
+
if (verticalAlign === 'middle') {
|
|
151
|
+
// Use bottom-center alignment but push up with MarginV
|
|
152
|
+
// For middle position, we want subtitle at ~45% from bottom
|
|
153
|
+
effectiveAlignment = horizontalAlign === 'left' ? 1 : horizontalAlign === 'right' ? 3 : 2;
|
|
154
|
+
marginV = 350; // Works for most video heights (720p-1080p)
|
|
155
|
+
}
|
|
156
|
+
else if (verticalAlign === 'top') {
|
|
157
|
+
marginV = paddingY;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// bottom
|
|
161
|
+
marginV = paddingY;
|
|
162
|
+
}
|
|
142
163
|
// 3. Convert colors to ASS format
|
|
143
164
|
const primaryColorASS = colorToASS(fontColor, 1);
|
|
144
165
|
const outlineColorASS = colorToASS(outlineColor, 1);
|
|
@@ -152,7 +173,7 @@ async function executeAddSubtitle(video, subtitleFile, style, itemIndex) {
|
|
|
152
173
|
}
|
|
153
174
|
else {
|
|
154
175
|
// SRT file: apply force_style
|
|
155
|
-
const forceStyle = buildForceStyle(fontName, fontSize, primaryColorASS, outlineColorASS, outlineWidth, backColorASS, enableBackground,
|
|
176
|
+
const forceStyle = buildForceStyle(fontName, fontSize, primaryColorASS, outlineColorASS, outlineWidth, backColorASS, enableBackground, effectiveAlignment, marginV);
|
|
156
177
|
subtitlesFilter = `subtitles='${escapedPath}':force_style='${forceStyle}'`;
|
|
157
178
|
}
|
|
158
179
|
const command = ffmpeg(video)
|
package/package.json
CHANGED