MediaFX icon

MediaFX

Process videos, audio, and media files with FFmpeg

Actions15

Overview

The node "MediaFX" provides video processing capabilities using FFmpeg, focusing on adding text subtitles to videos in this context. The "Add Text" operation under the "Subtitle & Text" resource allows users to overlay custom text onto a video source, specifying when the text appears and disappears, its font styling, color, size, position, and outline.

This node is beneficial for scenarios such as:

  • Adding captions or annotations to videos.
  • Creating branded video content with watermarks or titles.
  • Highlighting specific moments in a video with descriptive text.

For example, you can add a greeting message "Hello, n8n!" that appears from 0 to 5 seconds into a video, positioned at the bottom center with a white font and an outline.

Properties

Name Meaning
Video Source Defines the input video. Can be provided as a URL or binary data.
Text The text content to display on the video.
Start Time (seconds) The time in seconds when the text should start appearing on the video.
End Time (seconds) The time in seconds when the text should stop appearing.
Font Key The font used for the text. Options are dynamically loaded from available fonts. Default is "noto-sans-kr".
Font Size Size of the text in pixels. Default is 48.
Color Text color. Accepts color names (e.g., "white", "red") or hex codes (e.g., "#FF0000"). Default is "white".
Outline Width Width of the text border or outline in pixels. Default is 1.
Position Type How to position the text on the video. Two options:
- Alignment: Use preset alignment positions.
- Custom: Set custom X/Y coordinates using FFmpeg expressions.
Horizontal Alignment When using Alignment positioning, sets horizontal alignment: Left, Center, or Right. Default is Center.
Vertical Alignment When using Alignment positioning, sets vertical alignment: Top, Middle, or Bottom. Default is Bottom.
Horizontal Padding When using Alignment positioning, horizontal padding in pixels from left/right edges. Default is 20.
Vertical Padding When using Alignment positioning, vertical padding in pixels from top/bottom edges. 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 the added text as binary data under the binary.data property. The output JSON object is empty ({}), indicating that the main result is the binary video data.

  • binary.data: Contains the video file with the text overlay applied.
  • pairedItem.item: References the original input item index.

Dependencies

  • Requires FFmpeg installed and accessible in the environment where n8n runs.
  • Uses an API key credential or similar authentication if video sources require access control (not explicitly shown but typical for URL sources).
  • Dynamically loads available fonts from the system or user uploads.
  • Temporary files are managed and cleaned up automatically after processing.

Troubleshooting

  • No binary data found in property: If using binary input, ensure the specified binary property exists and contains valid video data.
  • Font file not found: When uploading fonts from a file path, verify the path is correct and accessible.
  • Operation did not produce an output: Indicates the processing failed silently; check input parameters and video source validity.
  • FFmpeg errors: May occur if FFmpeg is not installed or the command fails due to invalid parameters or unsupported formats.
  • Text not visible or misplaced: Check positioning properties and ensure the font supports the characters used.
  • Color issues: Use valid CSS color names or hex codes.

To resolve errors, verify inputs, ensure FFmpeg is properly installed, and confirm font availability.

Links and References

Discussion