MediaFX icon

MediaFX

Process videos, audio, and media files with FFmpeg

Actions15

Overview

The node "MediaFX" provides advanced video processing capabilities using FFmpeg, focusing on media transformations such as adding subtitles or text overlays to videos. Specifically, the Add Subtitle operation allows users to embed subtitle files into a video source, customizing font, size, color, outline, and positioning of the subtitles.

This node is beneficial in scenarios where automated video editing workflows are needed, such as:

  • Adding external subtitle files (e.g., SRT) to videos for accessibility or localization.
  • Customizing subtitle appearance to match branding or style guidelines.
  • Processing batches of videos with consistent subtitle styling.

Example use case: Automatically embedding translated subtitles into marketing videos hosted online by providing URLs for both the video and subtitle file, then specifying font and position options.

Properties

Name Meaning
Video Source Defines the input video to which subtitles will be added. Options:
- Source Type: URL or Binary Data.
- Value: URL string if URL selected.
- Binary Property: Binary data property name if binary selected.
Subtitle File Source Defines the subtitle file input. Options:
- Source Type: URL or Binary Data.
- Value: URL string if URL selected.
- Binary Property: Binary data property name if binary selected.
Font Key The font used for rendering subtitles. Loaded dynamically from available fonts. Default is "noto-sans-kr".
Font Size Size of the subtitle text in pixels. Default is 48.
Color Text color for subtitles. Can be named colors (e.g., white, red) or hex codes (e.g., #FF0000). Default is white.
Outline Width Width of the subtitle text border/outline in pixels. Default is 1.
Position Type How the subtitle text is positioned on the video. Options:
- Alignment: Use preset alignment positions.
- Custom: Specify custom X/Y coordinates using FFmpeg expressions.
Horizontal Alignment When using Alignment positioning, sets horizontal alignment of subtitles. Options: Left, Center, Right. Default is Center.
Vertical Alignment When using Alignment positioning, sets vertical alignment of subtitles. Options: Top, Middle, Bottom. Default is Bottom.
Horizontal Padding Padding in pixels from left/right edges when using Alignment positioning. Default is 20.
Vertical Padding Padding in pixels from top/bottom edges when using Alignment positioning. Default is 20.
Position X When using Custom positioning, defines the X coordinate using FFmpeg expressions (e.g., (w-text_w)/2). Default is (w-text_w)/2.
Position Y When using Custom positioning, defines the Y coordinate using FFmpeg expressions (e.g., h-th-50). Default is h-th-50.

Output

The node outputs the processed video file with subtitles embedded as binary data under the binary field named data. The json output is empty ({}) because the main result is the binary video file.

Output structure example:

{
  "json": {},
  "binary": {
    "data": {
      "data": "<Buffer ...>",
      "fileName": "output.mp4"
    }
  }
}
  • The binary data contains the final video file with subtitles burned in.
  • The original filename is preserved or generated during processing.

Dependencies

  • Requires FFmpeg installed and accessible in the environment where n8n runs.
  • Uses an API or internal method to load available fonts dynamically.
  • Supports input video and subtitle files via URLs or binary data.
  • No explicit external API keys are required, but access to video and subtitle URLs must be permitted.

Troubleshooting

  • No binary data found in property '...': Occurs if the specified binary property does not exist in the input item. Ensure the binary property name matches the incoming data.
  • Font file not found at path: ...: If uploading fonts from local paths, verify the file exists and the path is correct.
  • Operation did not produce an output: Indicates the processing step failed silently. Check input sources and parameters.
  • Invalid font key: Using a font key that does not exist in the available fonts list will cause errors. Validate font keys before use.
  • FFmpeg errors: May occur if FFmpeg is missing or incompatible. Confirm FFmpeg installation and version compatibility.

To resolve issues, verify inputs, ensure FFmpeg is installed, and check font availability.

Links and References

Discussion