Narrating over a Video using Multimodal AI n8n Workflow Template

n8n workflow template · 14 nodes · OpenAI

Narrating over a Video using Multimodal AI is a free n8n workflow template that starts when you run it manually in the n8n editor and works with OpenAI and Google Drive. It has 14 nodes, 3 of them AI nodes (OpenAI Chat Model, OpenAI and Basic LLM Chain). The notes inside the workflow say: “This template was inspired by Processing and narrating a video with GPT's visual capabilities and the TTS API” To run it, you add your own credentials for Google Drive OAuth2 and OpenAI API.

At a glance

Trigger
Manual Trigger (When clicking ‘Test workflow’)
Nodes
14
Apps
OpenAI and Google Drive
AI nodes
3
Credentials
2 types
Category
Spreadsheets, databases and docs

Apps and integrations

  • OpenAI
  • Google Drive

Node types used

  • OpenAI Chat Model
  • Code
  • Split Out
  • HTTP Request
  • Convert to File
  • Manual Trigger
  • Aggregate
  • Google Drive
  • Wait
  • Loop Over Items
  • Edit Image
  • OpenAI
  • Basic LLM Chain

How it works

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

Try It Out!

This n8n template takes a video and extracts frames from it which are used with a multimodal LLM to generate a script. The script is then passed to the same multimodal LLM to generate a voiceover clip.

This template was inspired by Processing and narrating a video with GPT's visual capabilities and the TTS API

  • Video is downloaded using the HTTP node.
  • Python code node is used to extract the frames using OpenCV.
  • Loop node is used o batch the frames for the LLM to generate partial scripts.
  • All partial scripts are combined to form the full script which is then sent to OpenAI to generate audio from it.
  • The finished voiceover clip is uploaded to Google Drive.

Sample the finished product here

Need Help?

Join the Discord or ask in the Forum!

1. Download Video

Learn more about the HTTP Request node

In this demonstration, we'll download a stock video from pixabay using the HTTP Request node. Feel free to use other sources but ensure they are in a format support by OpenCV (See docs)

The video used in this demonstration is © Coverr-Free-Footage via Pixabay

2. Split Video into Frames

Learn more about the Code node

We need to think of videos are a sum of 2 parts; a visual track and an audio track. The visual track is technically just a collection of images displayed one after the other and are typically referred to as frames. When we want LLM to understand videos, most of the time we can do so by giving it a series of frames as images to process.

Here, we use the Python Code node to extract the frames from the video using OpenCV, a computer vision library. For performance reasons, we'll also capture only a max of 90 frames from the video but ensure they are evenly distributed across the video. This step takes about 1-2 mins to complete on a 3mb video.

PERFORMANCE WARNING!

Using large videos or capturing a large number of frames is really memory intensive and could crash your n8n instance. Be sure you have sufficient memory and to optimise the video beforehand!

3. Use Vision AI to Narrate on Batches of Frames

Read more about the Basic LLM node

To keep within token limits of our LLM, we'll need to send our frames in sequential batches to represent chunks of our original video. We'll use the loop node to create batches of 15 frames - this is because of our max of 90 frames, this fits perfectly for a total of 6 loops. Next, we'll convert each frame to a binary image so we can resize for and attach to the Basic LLM node. One trick to point out is that within the Basic LLM node, previous iterations of the generation are prepended to form a cohesive script. Without, the LLM will assume it needs to start fresh for each batch of frames.

A wait node is used to stay within service rate limits. This is useful for new users who are still on lower tiers. If you do not have such restrictions, feel free to remove this wait node!

4. Generate Voice Over Clip Using TTS

Read more about the OpenAI node

Finally with our generated script parts, we can combine them into one and use OpenAI's Audio generation capabilities to generate a voice over from the full script. Once we have the output mp3, we can upload it to somewhere like Google Drive for later use.

Have a listen to the finished product here

Nodes in this workflow

The 14 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:

  1. OpenAI Chat Model (OpenAI Chat Model)
  2. Capture Frames (Code)
  3. Split Out Frames (Split Out)
  4. Download Video (HTTP Request)
  5. Convert to Binary (Convert to File)
  6. When clicking ‘Test workflow’ (Manual Trigger)
  7. Combine Script (Aggregate)
  8. Upload to GDrive (Google Drive)
  9. Stay Within Service Limits (Wait)
  10. For Every 15 Frames (Loop Over Items)
  11. Resize Frame (Edit Image)
  12. Aggregate Frames (Aggregate)
  13. Use Text-to-Speech (OpenAI)
  14. Generate Narration Script (Basic LLM Chain)

Credentials you need

  • Google Drive OAuth2 – used by Upload to GDrive
  • OpenAI API – used by OpenAI Chat Model and Use Text-to-Speech

Configure your own credentials after importing. Create each credential in n8n, then select it in the node.

How to import into n8n

  1. Download the JSON file with the button above.
  2. In n8n, open a new workflow, select the ... menu and choose Import from File. You can also paste the JSON straight into the editor canvas.
  3. Open each node that shows a warning and select or create its credential.
  4. Read the notes on the canvas, test the workflow with sample data, then activate it.

Do you need somewhere to run it? Read our guide to self-hosted n8n.

Need this customised?

We can adapt this workflow to your apps, data and process, then deploy and support it.

Contact Us