AI Video Composition with Custom Gemini Backgrounds - n8n Workflow

Use this robust n8n workflow to automatically generate custom backgrounds using Gemini AI and composite them with your foreground video, saving the result directly to Google Drive. Perfect for marketing and social media automation.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Content Creators and Video Editors needing quick, unique backgrounds.

  • Marketing Teams generating branded video assets.

  • Developers looking for a powerful, ready-made n8n templates for media processing via API.

  • Anyone seeking to leverage the power of n8n for complex AI-driven media pipelines.

Overview

Creating highly customized video content often requires complex layering and specialized software. This powerful n8n workflow automates the entire process, bridging the gap between imagination and final production. It solves the pain point of needing unique, high-quality backgrounds for videos without manual graphic design.

By leveraging the Gemini API for image generation (Nano Banana) and the VideoBGRemover service for composition, this n8n automation takes a simple prompt and a video URL and produces a final, professional composite video saved directly to your Google Drive. This specific n8n workflow is ideal for scaling video production where visual consistency and novelty are key.

How it Works

This n8n workflow functions primarily as an API endpoint triggered by an incoming HTTP POST request (Webhook) or run manually using the dedicated n8n trigger.


  1. Input Handling (Webhook/Manual Trigger): The n8n trigger captures the videourl, backgroundprompt, and aspectratio. The subsequent merge node funnels these inputs into the core processing path.

  2. AI Image Generation (Gemini): The first major n8n node utilizes the Gemini API via an HTTP Request. It sends the backgroundprompt and desired aspect_ratio to generate a high-quality, custom background image, returning it as Base64 data.

  3. File Staging: An n8n code node extracts the Base64 image data and converts it into a binary file. The n8n workflow then uploads this image to Google Drive, setting the permissions to public so that the external video service can access the staging file via URL.

  4. Video Composition (VideoBGRemover): The n8n workflow creates a video processing job, uploading the foreground video URL. It then initiates the composition process, referencing the public Google Drive URL of the newly generated AI background.

  5. Polling and Waiting: An important control flow element in this n8n workflow is the polling loop (Wait 20s and 6. Check Job Status n8n node). This logic repeatedly checks the job status until it is 'completed' or 'failed'.

  6. Final Output: Once complete, the n8n workflow downloads the final composite video and uses another Google Drive n8n node to upload the result permanently, structuring the file names using metadata. The final n8n node then constructs a detailed success response, which is returned immediately if the initial n8n trigger was a Webhook.

Installation Guide

To deploy and utilize this powerful n8n template, follow these steps:


  1. Import: Copy the provided JSON into your n8n instance using the 'Import from JSON' option.

  2. API Key Setup (Required): This n8n workflow relies on two secret variables. Go to Settings > Variables in your n8n instance and create the following environment variables:

GEMINIKEY: Your Google AI Studio API key for image generation.
VIDEOBGREMOVER
KEY: Your API key for the VideoBGRemover service.

  1. Google Drive Credentials: Configure the Google Drive n8n node. Click on the '2. Save Background Image to Drive' node, click 'Create New Credential', and authorize n8n to access your Google Drive account. Repeat this for the '8. Upload Video to Drive' n8n node.

  2. Testing: Use the 'Manual Trigger' and update the values in the 'Sample Inputs (Edit Here)' n8n node with your test video URL and background prompt. Execute the n8n workflow to verify functionality.

  3. Activation: Once testing is complete, switch the 'Webhook Trigger' n8n trigger to 'Active' to enable automated API calls.

Node Details

This n8n workflow utilizes several key n8n node types for advanced functionality:

Webhook Trigger: Acts as the external API endpoint for this n8n template, listening for POST requests to initiate video processing.
Set (Sample Inputs / Extract Webhook Data): Used to define or extract critical input variables (videourl, backgroundprompt, aspectratio) from the initial n8n trigger.
HTTP Request (1. Generate Background Image / 4. Create Job / 5. Start Composition / 6. Check Job Status / 7. Download Video): These are crucial n8n nodes for interacting with external APIs (Gemini and VideoBGRemover). They manage image generation, job creation, status polling, and final video download.
Key Configuration: Securely uses $vars.GEMINI
KEY and $vars.VIDEOBGREMOVER_KEY headers for authentication.
Code (Extract Image Data): A custom n8n node that processes the raw Base64 image data returned by the Gemini HTTP Request, converting it into a binary format consumable by the Google Drive n8n node.
Google Drive: Two instances of this n8n node are used: one to stage the AI-generated background (and make it public) and one to save the final composite video.
If (Is Complete? / Has Failed?): Provides flow control, checking the video job status before proceeding to download or error handling. A fundamental piece of core logic in this n8n workflow.
Wait (Wait 20s): Part of the polling loop, forcing a delay before the n8n workflow checks the processing status again.

Related n8n Workflows

Free

Nodes: 11 Nodes
Updated: December 26 2025
View all
Created by
Paul Roussel
Paul Roussel

Featured*