我的夥伴許博士利用AI Agent採用MiniMax H3做出一支,像《審時農曆》這種結合「AI 田間畫面 + 系統實錄 + 動態字卡」的 90 秒專業宣傳片。
我請Antigravity也做出一支一模一樣的影片,可以嗎? Gemini回答我:完全可以!你不需要打開剪輯軟體拉時間軸,只要利用 Google 最新推出的 Antigravity(AI 工作台),給它一把 Google AI API Key,Agent 就會扮演「總導演」幫你完成:呼叫 Veo 3/3.1 API 批次生成 8 個擬真田間鏡頭。 用程式碼自動繪製 4 個綠底白字卡(並修正加入 #167 提案編號)。 讀取你的 3 個 App 實錄畫面。 自動調用 FFmpeg 將 16 個鏡頭依時間碼接合,並壓上「概念影片」水印與中文字幕! 💰 製作成本:人力:0 小時(Agent 全自動寫 code + 渲染)API 費用:約 $5–$8 美金(約 NT$ 150–250 元)👇 完整的 Agent 指令與自動化 Python 程式碼放在下面,歡迎直接拿去用!💻 Agent 執行說明與程式碼只要在 Antigravity 中建立新專案,放入你的 assets/(內含 3 個實錄檔),並將以下指令與程式碼交給 Agent 執行即可:
給 Antigravity 的 Prompt 指令 請幫我在 Antigravity 建立一個自動化腳本 make_video.py。 讀取我的 GOOGLE_API_KEY,透過 google-genai SDK 呼叫 Veo 3 API 生成腳本中的 8 個 AI 鏡頭,並使用 MoviePy/FFmpeg 自動合成整支 89 秒的《審時農曆》宣傳片。
Agent 運行的自動化程式碼 (make_video.py)`import os
import time
from google import genai
from moviepy.editor import VideoFileClip, TextClip, ColorClip, CompositeVideoClip, concatenate_videoclips
API_KEY = os.getenv("GOOGLE_API_KEY", "YOUR_GOOGLE_AI_STUDIO_API_KEY")
client = genai.Client(api_key=API_KEY)
VEO_PROMPTS = {
"shot_1": "Photorealistic documentary style. A green knapsack pesticide sprayer resting against a wooden post at dawn. Morning mist, soft low sunlight. Slow push-in, no text.",
"shot_2": "Photorealistic close-up of a farmer's gloved hand gripping the metal handle of a knapsack sprayer and lifting it up. Overcast daylight, no text, no face.",
"shot_3": "Photorealistic documentary footage. A farmer in a wide-brim hat holding a knapsack sprayer, standing at the edge of a Taiwanese vegetable field. Mid-shot from behind, no face.",
"shot_4": "Photorealistic close-up of bok choy severely damaged by insects. Leaves full of small holes, wilted yellowing plants. Overcast daylight, no text.",
"shot_5": "Low-angle shot following irrigation water flowing along a narrow concrete channel away from a vegetable field toward distant village houses. Soft overcast light, no text.",
"shot_8": "Photorealistic close-up. A farmer's gloved hand resting motionless on top of a knapsack sprayer tank cap, not lifting it. Static tight shot, no text.",
"shot_11": "Photorealistic shot. A knapsack pesticide sprayer standing alone on soil at the edge of a bok choy field at dusk. Static camera, warm evening light, no people.",
"shot_13": "Photorealistic close-up of hands washing fresh green bok choy under running tap water in a kitchen sink. Natural window daylight, warm domestic feel."
}
def generate_veo_clips():
"""呼叫 Veo 3 API 批次生成 AI 影片"""
os.makedirs("generated_clips", exist_ok=True)
for key, prompt in VEO_PROMPTS.items():
output_path = f"generated_clips/{key}.mp4"
if os.path.exists(output_path):
continue
print(f"🎬 正在透過 Veo 3 生成鏡頭: {key}...")
operation = client.models.generate_videos(
model="veo-3.0-generate-001",
prompt=prompt,
config={"duration_seconds": 5, "aspect_ratio": "16:9"}
)
# 等待生成完成
while not operation.done:
time.sleep(10)
operation = client.operations.get(operation)
# 下載生成的影片檔案
video_result = operation.result.generated_videos[0]
client.files.download(file=video_result.file.name, destination=output_path)
print(f"✅ {key} 生成完畢!")
def render_final_video():
"""使用 MoviePy 自動剪輯、對齊時間軸並加上浮水印"""
print("✂️ 開始進行自動剪輯與合成...")
# 範例:組合 AI 鏡頭與實錄畫面 (根據腳本時間軸劃分)
clip1 = VideoFileClip("generated_clips/shot_1.mp4").subclip(0, 5) # 鏡 1
clip2 = VideoFileClip("generated_clips/shot_2.mp4").subclip(0, 2) # 鏡 2
# 載入系統實錄畫面
clip_sys9 = VideoFileClip("assets/app_record_1.mp4") # 第 9 鏡實錄
# 製作綠底字卡 (第 15 鏡投票卡,加入 #167)
card_text = "審時農曆\n提案編號 #167\n請幫我們投一票"
bg_card = ColorClip(size=(1920, 1080), color=(34, 139, 34), duration=6)
txt_card = TextClip(card_text, fontsize=50, color='white', font='Arial-Bold').set_duration(6).set_position('center')
card_clip15 = CompositeVideoClip([bg_card, txt_card])
# 串接所有片段
final_sequence = concatenate_videoclips([clip1, clip2, clip_sys9, card_clip15])
# 全程右上角加上「概念影片」浮水印
watermark = TextClip("概念影片", fontsize=28, color='white', opacity=0.7)
watermark = watermark.set_position(("right", "top")).set_duration(final_sequence.duration)
final_video = CompositeVideoClip([final_sequence, watermark])
# 渲染輸出 1080p 24fps 影片
final_video.write_videofile("shinong_v3_google_ai.mp4", fps=24, codec="libx264")
print("🎉 影片渲染完成:shinong_v3_google_ai.mp4")
if name == "main":
generate_veo_clips()
render_final_video()`
影片 : https://broadvision4u.com/formlog/vote