AI Video Clipper using Gemini and FFmpeg - n8n Workflow

Automate the creation of viral short clips from YouTube videos using this powerful n8n workflow. It leverages yt-dlp, FFmpeg, and Google Gemini AI to analyze transcripts, identify peak moments, perform 9:16 cropping, and burn dynamic subtitles automatically. Use this n8n template for fast content creation.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Content creators looking to repurpose long-form video into social media shorts.

  • Developers needing advanced examples of integrating shell commands (FFmpeg/yt-dlp) within an n8n template.

  • Users running self-hosted n8n who require complex, system-level automation.

  • Marketing teams aiming to rapidly test viral clips without manual editing.

Overview

The primary challenge this solution addresses is the labor-intensive process of manually reviewing long-form video content to find short, high-engagement clips, followed by the time-consuming process of editing (cropping, trimming, subtitling). This sophisticated n8n workflow completely automates that process. By integrating system-level tools like yt-dlp for downloading and FFmpeg for high-performance editing with the analytical power of the Gemini AI n8n node, this n8n workflow analyzes the video transcript to score and select the best moments. The result is a fully edited, vertical (9:16 aspect ratio) clip set, ready for immediate upload, maximizing content output efficiency. This specialized n8n template is designed for self-hosted environments.

How it Works


  1. Trigger and Download: The process starts with an On form submission n8n trigger where the user inputs the YouTube URL. Parallel Execute Command n8n node steps use yt-dlp to download both the video file and its corresponding SRT subtitle file.

  2. Transcript Preparation: Several Code n8n node steps extract the file paths, read the SRT content from disk, format it into clean, timestamped segments, and chunk the data for efficient AI processing.

  3. Viral Clip Identification: The viral clips identification Google Gemini n8n node analyzes the transcript chunks, using AI scoring to determine the top 10 most viral-worthy segments, returning precise start and end times for each.

  4. Data Merger: The original video path is merged with the list of AI-identified clips. The flow then enters a large loop to process each clip individually.

  5. Initial Clipping: An Execute Command n8n node uses FFmpeg to perform a quick initial clip extraction based on the AI's timestamps.

  6. Deep Editing Analysis: The binary data of the newly clipped video is sent to the Analyze the actual whole video Google Gemini n8n node. This AI is prompted with a strict JSON schema to generate a professional editing plan, including specific crop coordinates (for 9:16 vertical video) and detailed subtitle instructions.

  7. FFmpeg Command Generation: The extract all actionable operations Code n8n node parses the complex AI editing JSON and converts it into a sequential list of optimized FFmpeg commands (e.g., trimcrop, createsrt, subtitles).

  8. Execution and Subtitling: The workflow iterates through the generated commands. For subtitle burning, specialized Execute Command n8n node steps dynamically calculate the appropriate font size and placement relative to the video dimensions using ffprobe and then execute the final ffmpeg command.

  9. Completion: After all clips are processed and aggregated, a Gmail n8n node sends a notification confirming that the high-quality clips are available on the server.

Installation Guide


  1. Import the n8n Workflow: Copy the provided JSON data and paste it into your n8n instance using the 'Import from JSON' function.

  2. Prerequisites (Self-Hosted Only): This powerful n8n workflow requires system access. Ensure that yt-dlp and ffmpeg are installed and available in the execution environment of your n8n setup.

  3. Credential Setup:

Google Gemini (PaLM) API: Set up your Gemini API key credentials and attach them to the viral clips identification and Analyze the actual whole video n8n node instances.
Gmail OAuth2: Configure your Gmail credential and apply it to the Send a message n8n node for notifications.

  1. File Path Verification: If your n8n setup does not use the default Docker volume paths, you must update the hardcoded /data/clips/ path references in the Execute Command n8n node parameters (for yt-dlp and ffmpeg) to match your storage configuration.

  2. Execution: Activate the n8n workflow, navigate to the Webhook URL provided by the On form submission n8n trigger, and submit the YouTube link to begin the automated clipping process.

Node Details

On form submission (n8n trigger): The primary entry point, collecting the necessary YouTube URL and video title via a user form.
video download with yt-dlp / get transcript from yt-dlp (Execute Command n8n node): Utilizes external yt-dlp commands to fetch video and transcript data, which is essential for the AI analysis in the subsequent steps of this n8n workflow.
viral clips identification (Google Gemini n8n node): Analyzes the segmented transcript to find and score potential viral moments, providing precise timestamps (HH:MM:SS.mmm format) for targeted clipping.
filter out top clips according to score (Code n8n node): Aggregates results from multiple AI analysis chunks, sorts them by the calculated 'score', and retains the top candidates (default: 10 clips).
Analyze the actual whole video (Google Gemini n8n node): Receives the initial clip and performs a detailed analysis to generate a rigid, actionable JSON object containing professional editing instructions (9:16 crop coordinates, trimming, and micro-chunked subtitle structure).
extract all actionable operations (Code n8n node): Converts the complex editing instructions from the AI into a linear, sequential pipeline of explicit FFmpeg shell commands, preparing the data for the final Execute Command n8n node steps.
Execute operation on the clip (Execute Command n8n node): The core editing engine; executes the generated FFmpeg commands to apply trimming, cropping, and subtitle burning to create the final, polished short-form video.
Gmail (n8n node): Provides final communication, alerting the user when the automated clipping process is successfully completed.

Related n8n Workflows

Free

Nodes: 19 Nodes
Updated: December 26 2025
View all
Created by

Ai & Data science engineer | Automation expert who build's systems that deliver a ROI

Featured*