@lee-jisoo/n8n-nodes-mediafx 1.6.4 → 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
|
];
|
|
@@ -139,27 +142,16 @@ async function executeAddSubtitle(video, subtitleFile, style, itemIndex) {
|
|
|
139
142
|
paddingY = (_d = style.paddingY) !== null && _d !== void 0 ? _d : 20;
|
|
140
143
|
}
|
|
141
144
|
const alignment = getASSAlignment(horizontalAlign, verticalAlign);
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const videoInfo = await (0, utils_1.getVideoStreamInfo)(video);
|
|
146
|
-
if (videoInfo && videoInfo.height) {
|
|
147
|
-
videoHeight = videoInfo.height;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
catch (e) {
|
|
151
|
-
// Use default if ffprobe fails
|
|
152
|
-
console.warn('Could not get video height, using default 1080');
|
|
153
|
-
}
|
|
154
|
-
// Calculate MarginV based on vertical alignment and video height
|
|
155
|
-
// ASS MarginV is the distance from the alignment edge
|
|
156
|
-
// For middle alignment, we calculate the margin to center the subtitle
|
|
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
|
|
157
148
|
let marginV = paddingY;
|
|
149
|
+
let effectiveAlignment = alignment;
|
|
158
150
|
if (verticalAlign === 'middle') {
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
marginV =
|
|
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)
|
|
163
155
|
}
|
|
164
156
|
else if (verticalAlign === 'top') {
|
|
165
157
|
marginV = paddingY;
|
|
@@ -181,7 +173,7 @@ async function executeAddSubtitle(video, subtitleFile, style, itemIndex) {
|
|
|
181
173
|
}
|
|
182
174
|
else {
|
|
183
175
|
// SRT file: apply force_style
|
|
184
|
-
const forceStyle = buildForceStyle(fontName, fontSize, primaryColorASS, outlineColorASS, outlineWidth, backColorASS, enableBackground,
|
|
176
|
+
const forceStyle = buildForceStyle(fontName, fontSize, primaryColorASS, outlineColorASS, outlineWidth, backColorASS, enableBackground, effectiveAlignment, marginV);
|
|
185
177
|
subtitlesFilter = `subtitles='${escapedPath}':force_style='${forceStyle}'`;
|
|
186
178
|
}
|
|
187
179
|
const command = ffmpeg(video)
|
package/package.json
CHANGED