📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

AI контент-завод на n8n: как я автоматизировал создание Reels-видео с HeyGen, Elevenlabs и GPT

Олег Стефанов13:32

Transcription

Imagine you have a content factory that churns out reels without your involvement, 24/7. You just throw an idea into Telegram, and a few minutes later, you get a ready-made video with your avatar, background images, subtitles, and music. Sounds too cool to be true, right? But I built something like this in n8n in a few days. And now I'll tell you how it works, how much it costs, and how to launch such a process yourself. Let's go!

Hi, my name is Oleg. In my everyday life, I'm a developer, but on this channel, I'm more of a vibe coder. I write various things, try out AI tools, see what works and what doesn't. And today, I'll tell you how I built a content factory on n8n that churns out reels automatically.

What will we do today? We'll set up video generation with my avatar, integrate my cloned voice, add background image and music generation, and wrap it all up in n8n. And most importantly, I'll show you how much it all costs and if it's even worth the hassle. Let's dive in.

So, the heart of our content factory is HayGen. This is a service that can generate videos with AI avatars. You can scan yourself and then generate videos with your digital clone. When scanning, it's important to follow a couple of rules: the camera should be static, lighting should be more or less even, you need to speak clearly with pauses between sentences, and record at least 2 minutes of material. I recorded myself in a vertical format for reels. There's nothing complicated here, just follow the instructions on the HayGen website in the "Creating a Realistic Video Avatar" section.

We will be generating videos automatically, so let's look at the API pricing. The free plan offers 10 minutes per month with a watermark, which is suitable for testing. And the minimum paid plan is $99 per month for 100 minutes of generation. This means each minute of generation costs about $1.

To start working with the API, register on haygen.com, go to "Settings" -> "Subscriptions API" -> "Haygen API" -> "API Token Copy". Copy the key and paste it into the HTTP request node in n8n. To find your avatar ID, I call a separate HTTP request node and get a list of my avatars. I take the avatar ID and substitute it into the "Generation" request. For this, in the n8n workflow, I use a request to the "Generate Endpoint" with the following parameters. Here, I ask to generate a video with a blue background so that I can later replace it with images.

And an important point: generation happens asynchronously. I get a video ID, and then I use it to check the generation status. So, it's a cycle implemented through the "if" node plus "wait" in n8n.

As I mentioned earlier, to stitch all this together into one process, I use n8n. This system is an open-source no-code automation tool. It allows you to visually build processes without knowing programming. Well, almost.

How to set up n8n yourself? You can use n8n in the official cloud, which requires a paid subscription. However, to use it for free, you can set up n8n locally or on a server. I'll show you how to do it now. Install Docker, run this script, and then go to localhost:5678 in your browser. Create an account and use it for free. The full script for setting up n8n locally can be found in the video description.

The only nuance with n8n set up locally is that it cannot use network webhook features like Telegram triggers on messages. Therefore, I deployed it on my server in a similar way to use all possible functions.

How does the workflow work? n8n is created from blocks connected in a chain. Each node either triggers the start of a process or continues it by receiving the result of the previous node's execution as input. My main trigger here is a message in Telegram, as I want to give generation tasks using a Telegram message. For this, you need a Telegram bot token, which you can get from BotFather when creating a bot. I check that the message is from me by UserID so that no one else uses my bot. You can find out your ID by sending a message to the bot "GetUserID".

A minute of sponsor integration. Many neural networks from my video are available on the Syntax AI website. On it, you can easily test and try out a bunch of different text, photo, and video models – GPT, Claude, Gemini, SORA, Midjourney, Kling, Veo, and many others. You can pay with almost anything – crypto, SBP (Russian fast payment system), Russian or foreign cards, which is quite convenient. You don't need to get a thousand different subscriptions, connect VPNs, or deal with payments on foreign websites.

For example, I want to compare different text and image models available on the site. I want to see which ones are best suited for describing creepy videos with descriptions of objects like SCP. I've prepared a prompt like this: "VHS Found Footage Analog Horror," and so on. As a location, I have a McDonald's restaurant here. Let's go to the "Design" section, choose the Imagen 4 Ultra model, enter the prompt – not bad. Let's try generating the same thing on the Flux Context Max model – cool. I prefer the result from the Flux model; it's more murky and dim, just as I need it.

Let's also make a video from this picture using Veo 3. I upload the picture, choose the model, and in the prompt, something like "a walk." I start it – done. It looks cool, with such strange sounds. The model is really interesting. To use these and dozens of other neural networks, follow the link in the description and register. Try it today.

Returning to the video. And then a large chain of nodes is launched that create the final video. Let's look at them more closely. First, according to user instructions, a title and script are generated. I use an OpenAI node where I've specified the OpenRouter address, in which I've previously created an API key. OpenRouter is an aggregator of text neural networks where you can use models not only from OpenAI but also other versions from competitors like Gemini and Cloud. In my process, I use the Gemini model.

And then the script is fed into HayGen, where a video with the avatar's speech is generated. And by the way, this request also specifies the Voice ID, which allows you to select the correct voice for my avatar. I connect this from an external service. To make the voice sound more natural, I use Eleven Labs Professional Voice. This feature allows you to clone your voice at a reasonably acceptable level.

How did I clone my voice? I bought a subscription to Eleven Labs for $11 for the first month. It will be $22 later. I downloaded audio of my voice from the previous two YouTube videos, which amounted to about 1 hour. I uploaded it to Eleven Labs by clicking Voices -> Create a Clone Voice -> Professional Voice Clone. I waited for the model training to finish, which took a couple of hours. Then I got an API key by clicking on my name at the bottom -> API Keys -> Create API Key.

I connected Eleven Labs to HayGen. I went to AI Voice -> Integrate Third Party Voice -> Import Voice -> Eleven Labs and entered the API Key I copied from there. Then I obtained the Voice ID through a separate N8N node and substituted this ID into the node for preparing the video generation request.

The most important nuance for high-quality voice cloning with Eleven Labs is using Eleven Labs Multilingual V2 instead of V3, which generates interesting but, unfortunately, not very similar-sounding audio. Here are examples of V2 and V3 generated voices. And if you don't train the voice through Professional Voice Clone, the result might seem unnatural and uncomfortable for your voice.

After we get the video with the talking avatar, it's time to create the background. This will make the video more dynamic and interesting. I analyze the video transcription through an LLM and generate prompts for images for each piece of text. And here I used a small hack for parallel image generation. Usually, in n8n, data arrays are processed sequentially, which can be very slow when generating images. Therefore, I created a separate webhook process in n8n that generates one image. And then I placed a call to this webhook as an HTTP request in the main process, as HTTP requests in the process are executed in parallel by default. I used the OpenAI GPT Image 1 model for image generation. Each image has a random name and is saved to disk.

Then I create a special file for ffmpeg that specifies which image to show at what time, based on timestamps from ElevenLabs. And now the most interesting part: stitching all the elements into the final video. I have a video with an avatar on a blue background, a set of images with timings for when they should appear, and also a video transcription that can be used for subtitles.

To stitch the elements into one video, I used the ffmpeg utility. This is a command-line tool that can be called in any terminal. But it wasn't included in n8n by default, so I had to customize the Docker image to include it. I added this line to it: `run apk add`. Here is the final Dockerfile.

Rendering happens in several stages. First, the images are stitched into one background video. Then, the blue color on the avatar video is replaced with this video. At this stage, the result already looks good, but we can improve it by adding subtitles. Based on the transcription data from ElevenLabs, I create an SRT subtitle file, then render simple titles from it using ffmpeg. We get a result like this.

What if I told you that the Sahara was green? Yes, yes, it's true. Just 6,000 years ago, in place of these endless sands, there were savannas, rivers, and vast lakes. Giraffes, hippos, and even people lived there, leaving us amazing rock paintings. But due to a slight change in the Earth's axial tilt, the climate became drier, and the blooming land turned into a desert.

And the final touch is the background music. For uniqueness, I decided to generate it using the UDIO service. I use it via API through PiAPI. The process looks like this: the neural network analyzes the finished script and suggests a prompt for the soundtrack. A request is sent to generate music. Then the generation task status is checked in a loop until the soundtrack is ready. And then the music is mixed with the video. I lower the music volume by -25 dB so it doesn't overpower the speech. And this is the result we get.

Why do files download faster when everyone downloads them? Usually, you download a file from one server, and if everyone rushes there, the speed drops. But with torrents, it's different. The file is broken into thousands of small pieces, and you download them not from one place but from everyone at once. Everyone who is downloading simultaneously also shares the parts they already have. So, the more people involved, the more sources and the higher the speed for everyone. Teamwork.

And at each stage, I send a message to Telegram to track the process. This way, I always know at what stage the generation is and will understand if something went wrong.

And let's calculate the real cost of one minute-long video. Haygen: $1 per minute of generation via API. GPT image generation: around $0.5 for 5-7 images. UDIO music: $0.05 per track. LLM requests are cheaper than all, so let's round them up to $0.1 for all calls in the process. And Eleven Labs for $22 per month, which is more than enough. And we get approximately $1.87 for 100 one-minute videos per month.

It's not very clear if such an amount will pay off with some monetization. I'll check in practice later. But for AI experiments, it's a pretty interesting thing. Plus, this system can be significantly upgraded by adding idea sources, more sophisticated validation of finished scripts, and improving visual effects. You can also try working with non-existent characters using the photo token in Heygen. For example, here I generated a character and made her speak in a video.

The main skill of a coder in 2024 is not a new language or neural networks. It's a guide. Imagine a time machine for your code. If you want to test this flow yourself, the JSON of my n8n schema is in the description, which you can easily import and use. Instructions are included.

In general, such an AI content factory is a really cool thing. It allows you to generate a huge number of videos with almost no effort from the human side. You can create huge networks of channels if such content turns out to be profitable. I'm afraid to imagine what the internet will turn into with the development of such technologies for avatars and video generation. And it's interesting that such automations can be done almost without knowing programming, using no-code solutions like n8n. But it's important to remember that there's no magic here yet. Each stage of the process needs to be thought through, building the architecture manually. But I'm sure that AI and no-code technologies will develop even faster, allowing us to do even more wonderful things.

So, subscribe. Here I will review tools and technologies, projects and automations, show what worked for me. Also, check out my Telegram channel. I post my thoughts there more often, talk about my experience and experiments, share results. The link is in the description. And if you need to automate something, integrate AI, or do some complex task, write to me in direct messages on Telegram. I'll consult and advise. That's all for me. See you.