Skip to main content

Filter

Applies FFmpeg filters to transform video and audio streams. Filters enable operations like scaling, cropping, rotating, overlaying, concatenating, and applying visual or audio effects.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Filter Name - Name of the FFmpeg filter to apply. Examples include:

    • scale - Resize video
    • crop - Crop video to specified dimensions
    • overlay - Overlay one video on another
    • concat - Concatenate multiple videos
    • rotate - Rotate video
    • hflip / vflip - Flip horizontally/vertically
    • drawtext - Add text overlay
    • volume - Adjust audio volume
  • Streams - Array of stream IDs to apply the filter to. Can be from Input nodes or previous Filter nodes.

  • Custom Streams - Additional streams added as individual fields.

Options

  • Filter Options - Array of filter-specific options. The available options depend on the filter being used. Examples:

    • For scale: ["w=1280", "h=720"]
    • For crop: ["w=640", "h=480", "x=0", "y=0"]
    • For drawtext: ["text=Hello World", "fontsize=24", "x=10", "y=10"]
  • Custom Filter Options - Individual filter options added as separate fields. Each option should follow the format:

    • key=value for options with values
    • Positional arguments for filters that accept them

Output

  • stream_id - Filtered stream identifier. This new stream ID represents the result of applying the filter and can be used by Output nodes or additional Filter nodes for further processing.

How It Works

The Filter node applies transformations to media streams. When executed, the node:

  1. Validates that the filter name and at least one stream are provided
  2. Retrieves the input stream(s) from the session
  3. Parses filter options into arguments and keyword arguments
  4. Applies the specified filter with the given options
  5. Returns a new stream ID representing the filtered output

Filters can be chained together, with the output of one filter becoming the input to another.

Common Filters Reference

Video Filters

scale - Resize Video

Resize video to specific dimensions.

Options:

  • w - Width in pixels (or -1 for auto)
  • h - Height in pixels (or -1 for auto)

Example:

Filter Name: "scale"
Filter Options: ["w=1280", "h=720"]

crop - Crop Video

Extract a rectangular region from the video.

Options:

  • w - Crop width
  • h - Crop height
  • x - X offset from left (default: center)
  • y - Y offset from top (default: center)

Example:

Filter Name: "crop"
Filter Options: ["w=640", "h=480", "x=100", "y=50"]

rotate - Rotate Video

Rotate video by specified angle.

Options:

  • angle - Rotation angle in radians
  • c - Color for unfilled area (default: black)

Example:

Filter Name: "rotate"
Filter Options: ["angle=PI/2"] // 90 degrees

overlay - Overlay Videos

Place one video on top of another.

Options:

  • x - X position (default: 0)
  • y - Y position (default: 0)
  • shortest - End when shortest input ends (default: 0)

Example:

Filter Name: "overlay"
Streams: [background_stream, overlay_stream]
Filter Options: ["x=10", "y=10"]

concat - Concatenate Videos

Join multiple videos sequentially.

Options:

  • n - Number of input segments
  • v - Number of output video streams (default: 1)
  • a - Number of output audio streams (default: 0)

Example:

Filter Name: "concat"
Streams: [stream1, stream2, stream3]
Filter Options: ["n=3", "v=1", "a=1"]

drawtext - Add Text Overlay

Add text to video.

Options:

  • text - Text to display
  • fontfile - Path to font file
  • fontsize - Font size
  • fontcolor - Text color
  • x - X position
  • y - Y position
  • box - Draw background box (1 or 0)
  • boxcolor - Box color

Example:

Filter Name: "drawtext"
Filter Options: [
"text=Processing Complete",
"fontsize=48",
"fontcolor=white",
"x=(w-text_w)/2",
"y=(h-text_h)/2",
"box=1",
"boxcolor=black@0.5"
]

hflip / vflip - Flip Video

Flip video horizontally or vertically.

Example:

Filter Name: "hflip"  // No options needed

trim - Trim Video

Extract a time segment from video.

Options:

  • start - Start time in seconds
  • end - End time in seconds
  • duration - Duration in seconds

Example:

Filter Name: "trim"
Filter Options: ["start=10", "end=30"]

fps - Change Frame Rate

Modify the frame rate of video.

Options:

  • fps - Target frame rate

Example:

Filter Name: "fps"
Filter Options: ["fps=30"]

Audio Filters

volume - Adjust Volume

Change audio volume level.

Options:

  • volume - Volume multiplier (1.0 = normal, 2.0 = double, 0.5 = half)

Example:

Filter Name: "volume"
Filter Options: ["volume=2.0"] // Double volume

atrim - Trim Audio

Extract audio segment.

Options:

  • start - Start time in seconds
  • end - End time in seconds

Example:

Filter Name: "atrim"
Filter Options: ["start=5", "end=15"]

afade - Audio Fade

Apply fade in/out effect.

Options:

  • t - Type: in or out
  • st - Start time
  • d - Duration

Example:

Filter Name: "afade"
Filter Options: ["t=in", "st=0", "d=3"] // 3-second fade in

Practical Examples

Example 1: Resize Video to 720p

Filter Name: "scale"
Streams: [input_stream_id]
Filter Options: ["w=1280", "h=720"]

Example 2: Crop Video to Square

Filter Name: "crop"
Streams: [input_stream_id]
Filter Options: ["w=1080", "h=1080", "x=(in_w-1080)/2", "y=(in_h-1080)/2"]

Example 3: Add Watermark

// Assuming:
// main_video_stream - main video
// watermark_stream - watermark image/video

Filter Name: "overlay"
Streams: [main_video_stream, watermark_stream]
Filter Options: ["x=W-w-10", "y=H-h-10"] // Bottom-right corner with 10px margin

Example 4: Concatenate Three Videos

Filter Name: "concat"
Streams: [stream1, stream2, stream3]
Filter Options: ["n=3", "v=1", "a=1"]

Example 5: Add Text Timestamp

Filter Name: "drawtext"
Streams: [video_stream]
Filter Options: [
"text='%{localtime\\:%Y-%m-%d %H\\\\:%M\\\\:%S}'",
"fontsize=24",
"fontcolor=white",
"x=10",
"y=10",
"box=1",
"boxcolor=black@0.7"
]

Example 6: Create Picture-in-Picture

// First, scale the overlay video
Filter 1:
Filter Name: "scale"
Streams: [overlay_stream]
Filter Options: ["w=320", "h=180"]
Output: scaled_overlay

// Then overlay it on the main video
Filter 2:
Filter Name: "overlay"
Streams: [main_stream, scaled_overlay]
Filter Options: ["x=W-w-10", "y=10"]

RPA Automation Scenarios

Scenario 1: Process Screen Recording

Resize a screen recording and add company logo:

Create →
Input (recording.mp4) → recording_stream
Input (logo.png) → logo_stream

Filter (scale, recording_stream) → scaled_stream
Filter (overlay, [scaled_stream, logo_stream]) → final_stream
→ Output → Run

Scenario 2: Merge Training Videos

Concatenate multiple training video segments:

Create →
Input (intro.mp4) → intro_stream
Input (content.mp4) → content_stream
Input (outro.mp4) → outro_stream
→ Filter (concat, [intro_stream, content_stream, outro_stream]) → merged_stream
→ Output → Run

Scenario 3: Create Video Thumbnail Grid

Extract frames and create a thumbnail grid (requires complex filter):

Filter Name: "select"
Filter Options: ["gte(n\\,0)", "eq(n\\,0)"]
// Extract specific frames for thumbnail

Scenario 4: Add Progress Information

Add dynamic text showing processing progress:

Filter Name: "drawtext"
Filter Options: [
"text='Processed by Robomotion RPA'",
"fontsize=20",
"fontcolor=white",
"x=(w-text_w)/2",
"y=h-40",
"box=1",
"boxcolor=blue@0.8"
]

Error Handling

The node will return errors in the following cases:

  • "Filter Name cannot be empty" - No filter name provided
  • "Stream should be provided" - No input streams specified
  • "Invalid stream id" - One or more stream IDs don't exist
  • Invalid filter name - The specified filter doesn't exist in FFmpeg
  • Invalid filter options - Options are malformed or incompatible with the filter

Usage Notes

  • Filter names are case-sensitive
  • Some filters require specific numbers of input streams (e.g., overlay needs 2)
  • Filter options syntax varies by filter - consult FFmpeg documentation for specific filters
  • Complex filters can be built by chaining multiple Filter nodes
  • Video and audio filters are different - use appropriate filters for each stream type
  • Expressions can be used in filter options (e.g., x=(w-text_w)/2 for centering)

Performance Tips

  1. Filter Order Matters: Apply filters in efficient order (e.g., crop before scale)
  2. Minimize Filters: Combine operations when possible
  3. Use Hardware Acceleration: Some filters support GPU acceleration
  4. Cache Intermediate Results: For repeated processing, save intermediate filtered streams
  5. Test with Small Files: Develop filter chains with small test files first

Common Errors and Solutions

Error: "Filter not found"

Cause: The specified filter name doesn't exist or is misspelled. Solution: Verify the filter name against FFmpeg documentation. Common filters: scale, crop, overlay, concat, drawtext.

Error: "Option not found"

Cause: Using an option that doesn't exist for the filter. Solution: Check the filter's documentation for valid options.

Error: "Invalid filter graph"

Cause: Incompatible stream types or incorrect number of inputs. Solution: Ensure you're using the right number and type of streams for the filter.

Error: "No such filter"

Cause: The filter exists but isn't compiled in your FFmpeg build. Solution: Verify your FFmpeg build includes the filter or use an alternative.

Advanced Filter Examples

Complex Resize with Padding

Filter Name: "scale"
Filter Options: [
"w=1920",
"h=1080",
"force_original_aspect_ratio=decrease"
]
// Then add padding filter to fill to exact size

Blur Effect

Filter Name: "boxblur"
Filter Options: ["luma_radius=5", "luma_power=1"]

Fade In/Out Video

// Fade in
Filter Name: "fade"
Filter Options: ["t=in", "st=0", "d=2"]

// Fade out
Filter Name: "fade"
Filter Options: ["t=out", "st=28", "d=2"] // If video is 30 seconds

Speed Up/Slow Down

// Speed up 2x
Filter Name: "setpts"
Filter Options: ["PTS/2"]

// Slow down 2x
Filter Name: "setpts"
Filter Options: ["2*PTS"]

Best Practices

  1. Read FFmpeg Documentation: Each filter has extensive documentation - consult it for advanced options
  2. Test Incrementally: Test each filter separately before combining
  3. Use Variables for Options: Store complex filter options in variables for reusability
  4. Handle Edge Cases: Consider how filters behave with different input dimensions and formats
  5. Chain Efficiently: Plan your filter chain to minimize processing steps
  6. Validate Inputs: Use Probe node to check stream properties before filtering
  • Input - Provides source streams for filtering
  • Output - Receives filtered streams for output
  • Create - Initializes the session containing all streams
  • Run - Executes the complete FFmpeg command including filters

Additional Resources

For comprehensive filter documentation, refer to: