🐷
【完全解説】AIエージェントで動画を全自動生成!n8nを使ったYouTube動画作成ワークフロー
【完全解説】AIエージェントで動画を全自動生成!n8nを使ったYouTube動画作成ワークフロー
はじめに
最近話題のAIエージェントを使って、YouTube動画を完全自動で作成する方法をご存知でしょうか?人気YouTuberのような高品質な動画を、たった20-30分の設定で自動生成できる時代が到来しました。
この記事では、n8nというワークフロー自動化ツールを使って、台本作成から動画生成まで全自動で行うAIエージェントの構築方法を、初心者向けに詳しく解説します。
📊 全体構成が分かるスライド資料
本記事の内容を図解でまとめたスライド資料も用意しました。視覚的に理解したい方はこちらもご活用ください。
👉 AIエージェント動画生成ワークフロー 完全解説スライド
📊 このシステムで実現できること
- 所要時間: 初期設定20-30分、その後は完全自動
- 生成速度: 1本の動画を5-10分で自動生成
- 品質: YouTube投稿可能なプロレベル
- コスト: 従来の動画制作の1/10以下
🔄 システム構成の全体像
このAIエージェントは3つのステップで構成されています:
ステップ1: 動画生成用プロンプト準備
- Googleスプレッドシートから動画のアイデアを取得
- ChatGPTで台本を自動生成
ステップ2: 動画生成
- 音楽生成(Suno AI)
- 動画テンプレート作成(json2video)
ステップ3: 動画確認と管理
- 生成状況の監視
- エラーハンドリング
- 完成動画の保存
🛠️ 使用するツールとサービス
サービス | 役割 | 無料枠 |
---|---|---|
n8n | ワークフロー制御 | 5,000実行/月 |
ChatGPT | 台本・プロンプト生成 | $5クレジット |
Suno AI | BGM自動生成 | 50クレジット/日 |
json2video | 動画合成 | 10本/月 |
Google Sheets | データ管理 | 無制限 |
📝 完全ステップバイステップ構築ガイド
STEP 1: n8nワークスペースの準備
1-1. n8nアカウント作成
1. ブラウザで「n8n」と検索
2. 「n8n.io」をクリック
3. 右クリック → 「日本語に翻訳」
4. 「無料で始める」ボタンをクリック
5. メールアドレスとパスワードを入力
6. 「Start Free Trial」をクリック
1-2. ワークフロー作成
1. 「Start from scratch」を選択
2. 右クリック → 「日本語に翻訳」
3. 「最初の手順を追加」のプラスボタンをクリック
4. 「手動でトリガーする」を選択
STEP 2: Googleスプレッドシートの準備と連携
2-1. ChatGPTでアイデア生成
以下のプロンプトをChatGPTに入力して、動画アイデアを生成します:
以下の設定で動画アイデアを生成してください:
• TOPIC: 〔80歳の賢人が語る人生の教え〕
• COUNT: 〔5〕
• CHANNEL KEYWORDS: 〔成功する方法、人生の教訓、人生のたとえ話〕
次の列をこの順番で持つ表を生成してください:
| 列名 | 説明 |
|------|------|
| ID | 1から始めて1ずつ増加 |
| アイデア | TOPICに合った7〜10語以内の短いYouTubeタイトル(重複なし) |
| キャプション | 1行目:動画の説明/2行目:チャンネル紹介/3行目:チャンネル登録を促すCTA(末尾に関連ハッシュタグを3つ付ける |
| チャンネルスタイルプロンプト | 発展させ、5〜10語程度で表現 |
| キャラクタースタイルプロンプト | アイデアとトピックに合うユニークで詳細なビジュアルキャラクター(重複不可) |
| 制作状況 | 常に「要作成」 |
| 最終出力 | 空欄のまま |
| 公開状況 | 常に「作成前」 |
| エラーログ | 空欄のまま |
【重要なルール】
- 出力に二重引用符(")を含めないこと
- 生成する行数はCOUNTに一致させること
2-2. Googleスプレッドシートの設定
1. 新しいGoogleスプレッドシートを作成
2. ChatGPTで生成した表をコピー&ペースト
3. 「シート2」を作成し、以下の列を追加:
- 音楽URL
- イントロ動画URL
- To use(「final」と入力)
2-3. n8nでGoogleスプレッドシート連携
1. プラスボタン → 「Google Sheets」と検索
2. 「シート内の行を取得する」を選択
3. Googleアカウントと連携
4. 作成したスプレッドシートを選択
5. シート: 「シート1」
6. フィルター設定:
- 列: 「制作状況」
- 値: 「要作成」
7. オプション → 「最初に一致した行のみ返す」をON
STEP 3: ChatGPT連携設定
3-1. LLMチェーンモジュールの追加
1. プラスボタン → 「Basic LLM」と検索
2. 「基本LLMチェーン」を選択
3. 名前を「Prompt」に変更
3-2. プロンプト設定
ユーザープロンプト:
動画タイトル: {{ $json['アイデア'] }}
動画内容: {{ $json['キャプション'] }}
システムプロンプト:
あなたは熟練のプロンプトエンジニアです。
必ず日本語でアウトプットしてください。
あなたのタスクは、連続した動画用にボイスオーバーと画像プロンプトをシーン順に作成することです。
これらは短編動画の物語構成に従う必要があります。
イントロ (シーン1–3)
ビルドアップ (シーン4–6)
結論 (シーン7–10)
ユーザーは制作する動画のタイトルと説明を提供します。
タスク (TASK):
以下の形式で11個のオブジェクトからなるJSON配列を返してください。
voiceText 出力
voiceText: 2文構成のボイスオーバー。各voiceTextは必ず11〜15語で構成してください。
前のシーンとつながり、物語を滑らかに進行させる必要があります。
このvoiceTextは、以下に示すチャンネルのニッチ、トピック、スタイルに完全に準拠してください。
style and topic
{{ $json['チャンネル スタイル プロンプト'] }}
各voiceTextは繊細で知的に作られていますが、難解ではありません。必要に応じて下記メインキャラクターを用いた比喩やアナロジーを使用してください。
image_prompt 出力
image_prompt: 鮮明でシネマティック、かつ非常に詳細なビジュアルプロンプト。環境、被写体、ライティング、ムード、構図を細部まで描写し、前景と背景も記述してください。各image_promptの末尾には必ず下記Styleをそのまま記載してください。キャラクターを含める場合は、下記メインキャラクターの説明を必ず使用してください。image_promptは700文字以上とし、とくにキャラクターの背景描写を過度に詳述してください。
メインキャラクターの説明:
{{ $json['キャラクター スタイル プロンプト'] }}
重要要件 (CRITICAL REQUIREMENT)
すべてのシーンはスムーズにつながり、ボイスオーバーとビジュアルが1本の動画として流れる必要があります。視聴者が連続したストーリーとして視聴することを想定してください。プロンプト間の重複は避けてください。
説明を含めず、配列のみを返してください。
3-3. OpenAI接続設定
1. 「モデル」→ プラスボタン → 「OpenAI Chat Model」
2. OpenAI APIキーを取得(platform.openai.com)
3. n8nで新しい資格情報を作成してAPIキーを入力
3-4. 構造化出力パーサー設定
1. 「特定の出力形式が必要」をON
2. 「構造化出力パーサー」を選択
3. 以下のJSONを「JSONの例」に貼り付け:
[
{
"voiceText": "Son, when you feel hope slipping away, remember — real strength is forged in these moments.",
"image_prompt": "An elderly man in a worn coat stands on a rainy street corner, leaning on a cane, a weathered face full of wisdom beneath a dripping hat, the wet pavement reflecting the glow of distant streetlights, his eyes holding decades of experience and understanding, raindrops creating a contemplative atmosphere around his dignified figure, the urban landscape behind him blurred but suggesting the complexity of life's journey, his posture conveying both vulnerability and unshakeable inner strength."
},
{
"voiceText": "The world may seem dark, but mark my words — your fire inside will never die unless you let it.",
"image_prompt": "A dim room where an old, calloused hand lights a single candle, illuminating deep wrinkles and gentle eyes in the golden glow, books and personal mementos scattered on a wooden table, shadows dancing on weathered walls, the flame representing hope and resilience, warm light contrasting with the surrounding darkness, creating an intimate atmosphere of wisdom being passed down through generations, dust particles visible in the candlelight adding to the timeless quality of the scene."
},
{
"voiceText": "In the silence of your hardest nights, listen carefully — your true spirit still speaks.",
"image_prompt": "An old man sits alone by a rain-soaked window in a quiet cafe, his thoughtful gaze lost beyond the glass into the stormy night, steam rising from a cup of coffee warming his hands, the window reflecting both his image and the turbulent weather outside, creating a metaphor for inner reflection during difficult times, soft interior lighting contrasting with the harsh elements beyond, the cafe's warm atmosphere providing sanctuary from life's storms."
},
{
"voiceText": "Every heavy step you take, boy, that's proof you're still fighting. That's courage, plain and simple.",
"image_prompt": "Close-up of battered old boots splashing through muddy puddles on a cracked city sidewalk, worn leather telling stories of countless journeys, water droplets caught in motion around the determined stride, the urban environment showing signs of wear but also resilience, each step creating ripples that mirror the impact of perseverance, the ground beneath reflecting the ongoing struggle and determination to move forward despite obstacles."
},
{
"voiceText": "You ain't the first to walk through hard times — every great soul has felt this same weight.",
"image_prompt": "A wall covered with faded, black-and-white portraits of men and women whose eyes tell stories of hardship and hope, each photograph capturing a moment of human dignity and strength, the collection spanning different eras and backgrounds, soft lighting highlighting the emotional depth in each face, creating a visual testament to the universal nature of struggle and the shared human experience of overcoming adversity."
},
{
"voiceText": "Struggle ain't your enemy, son — it's the hands shaping you into the man you're destined to be.",
"image_prompt": "A shadowed figure practicing alone in a quiet boxing gym, heavy bags swaying slightly under dim overhead lights, sweat glistening on determined features, the atmosphere thick with dedication and self-improvement, vintage equipment and motivational posters creating an environment of transformation, the solitary training session representing the personal battle for growth and self-discovery, rays of light cutting through the darkness to illuminate moments of intense focus."
},
{
"voiceText": "Remember, boy — pain don't break you. It carves you into something greater than you ever thought you could be.",
"image_prompt": "An aged sculptor, deep in concentration, chiseling away at a stone statue, dust and small stone fragments filling the workshop air, years of artistic wisdom evident in every careful strike, the emerging figure representing human potential being revealed through patient effort, tools of the trade scattered around the workspace, natural light streaming through workshop windows creating dramatic contrasts between light and shadow, the creative process serving as metaphor for personal transformation."
},
{
"voiceText": "Each morning you wake up, you get another chance to swing back harder at life.",
"image_prompt": "Golden sunrise spilling over a sleepy city skyline, an old figure standing tall on a rooftop, cane in hand, facing the day with quiet determination, the urban landscape awakening below, birds beginning their morning songs, the warm light symbolizing new possibilities and fresh starts, silhouettes of buildings creating a dramatic backdrop for this moment of contemplation and renewal, the figure's posture conveying both wisdom gained and readiness for whatever challenges the day may bring."
},
{
"voiceText": "Storms always pass, son. You just got to outlast 'em — and you will.",
"image_prompt": "Dark, menacing clouds above a gray city — but a bright beam of sunlight pierces through, lighting up an old man staring skyward with a knowing smile, the dramatic contrast between storm and light creating a powerful visual metaphor, his upturned face showing complete faith in better times ahead, the urban environment below appearing to wait in anticipation of the clearing weather, the single ray of light serving as a beacon of hope cutting through adversity."
},
{
"voiceText": "Life's a long road, boy, but every rough mile brings you closer to the man you're meant to be.",
"image_prompt": "An exhausted but smiling elder reaching the top of a long staircase under pouring rain, the city stretching out behind him like a map of life's journey, each step representing progress through hardship, his expression mixing fatigue with triumph, the rain adding dramatic intensity to the moment of achievement, the elevated viewpoint offering perspective on how far he has traveled, street lights below creating a constellation of human activity and shared experience."
}
]
STEP 4: 音楽生成(Suno AI)
1. Suno AIにアクセス(suno.ai)
2. 「Make a song」→「Create」
3. プロンプト例:「モチベーションが上がるような低く、かっこいい重低音の音楽、インストゥルメンタル」
4. 生成された音楽をダウンロード
5. Googleスプレッドシートのシート2の「音楽URL」に保存
STEP 5: json2video設定
1. json2video.com にアクセス
2. アカウント作成・APIキー取得
3. 「Movie Templates」→「Add Template」
4. オーディオ要素とビデオ要素を追加
5. テンプレートIDを記録
STEP 6: n8nでHTTPリクエスト設定
1. プラスボタン → 「HTTP Request」
2. 方式: POST
3. URL: https://api.json2video.com/v2/movies
4. 認証: ヘッダー認証(X-API-Key)
5. 本文: JSON形式で動画生成リクエスト
STEP 7: 条件分岐とエラーハンドリング
1. 待機モジュール(5秒)を追加
2. 生成状況確認用HTTPリクエスト(GET)を追加
3. スイッチモジュールで3つの分岐を作成:
- "done"(完了): Googleスプレッドシートに結果を記録
- "running"(生成中): 30秒待機後、再確認
- "error"(エラー): エラーログを記録
✅ テスト実行と確認
1. 「テストワークフロー」をクリック
2. 各モジュールの実行状況を確認
3. 最終的にGoogleスプレッドシートに完成動画URLが記録されることを確認
🎯 生成される動画の例
- 長さ: 30秒〜1分程度
- 品質: YouTube投稿可能なHD画質
- 内容: モチベーション系、教育系など多様なジャンル対応
- 音声: 自然な日本語ナレーション
- BGM: 自動生成された高品質音楽
🔧 よくあるエラーと対処法
json2videoエラー:
エラー: "prompt is required for image element"
対処: JSONデータから空の要素を削除
OpenAI APIエラー:
エラー: "API key invalid"
対処: APIキー再確認、課金状況確認
Googleスプレッドシート権限エラー:
エラー: "Access denied"
対処: 共有設定確認、アカウント連携再実行
📊 まとめ
今回紹介したAIエージェントシステムにより、以下が実現できます:
✅ 完全自動化: 人の介入なしで高品質動画を生成
✅ 高速生成: 1本の動画を5-10分で生成
✅ コスト効率: 従来の1/10以下のコストで制作
✅ 品質の一貫性: プロレベルの動画を安定して生成
AIエージェントの時代は既に始まっています。 このワークフローをマスターすることで、コンテンツ制作の新しい可能性を切り開き、競合他社に大きく差をつけることができるでしょう。
🔗 関連リンク
この記事が役に立ったら、ぜひスキ❤️やフォローをお願いします!
Discussion