ทำวิดีโอ AI ในเครื่องตัวเอง — คู่มือติดตั้ง ComfyUI + Remotion + HyperFrames

คู่มือติดตั้ง ComfyUI + Remotion + HyperFrames

คู่มือติดตั้ง ComfyUI + Remotion + HyperFrames

วิดีโอนี้ทำขึ้นจากคอมพิวเตอร์ส่วนตัวล้วนๆ ไม่ใช้ Runway ไม่ใช้ Sora ไม่ใช้ Kling ไม่ใช้ Pika ไม่ส่ง API call ออกอินเทอร์เน็ตแม้แต่ครั้งเดียว

ต้นทุนตลอดการผลิต — ค่าไฟ 30 บาท

ทุกบริการ AI video ออนไลน์คิดค่า credit ทุกครั้งที่ generate ทำคลิป 15 ช็อต เท่ากับ 15 credit ลอง iterate prompt 3 รอบ เท่ากับคูณ 3 เทียบกับ Runway ที่ราว 0.05 USD ต่อวินาที video output คลิป 46 วินาทีเท่ากับราว 80 บาท บวกค่าทดลอง 3-5 รอบ รวม 300-400 บาทต่อคลิป

local stack ที่ 30 บาทต่อคลิป ประหยัด 95% และข้อมูลไม่ออกจากเครื่อง บทความนี้คือคู่มือติดตั้งทั้ง 3 เครื่องมือสำหรับคนที่ไม่เคยใช้มาก่อน


ชุดเครื่องมือ 3 ตัวที่ทำงานร่วมกัน

ComfyUI สั่งโมเดล AI สร้างภาพและวิดีโอ ทำงานบนการ์ดจอ NVIDIA โหลดโมเดลฟรีจาก HuggingFace ใช้ได้ทุกตัว (Flux, Wan, PuLID, ControlNet)

Remotion เขียนวิดีโอด้วยโค้ด React สำหรับ compose คลิปหลายๆ ตัวเป็นวิดีโอเดียว ใส่ caption, transition, overlay

HyperFrames stack ที่ครอบ Remotion + ComfyUI + browser-based rendering ออกแบบให้เขียน composition ด้วย HTML/CSS ที่ deterministic + มี text-to-speech, transcription, background removal ในตัว

ทั้งสามเป็น open source


สิ่งที่ต้องเตรียมก่อนติดตั้ง

  • การ์ดจอ NVIDIA RTX 3060 ขึ้นไป แนะนำ VRAM อย่างน้อย 12 GB
  • พื้นที่ดิสก์ว่าง 100 GB
  • Node.js LTS เวอร์ชัน 18+ จาก nodejs.org
  • โปรแกรม code editor เช่น VS Code
  • คู่มือนี้อิง Windows 10/11 (Mac/Linux ใช้ขั้นตอนคล้ายกัน)

ส่วนที่ 1 — ติดตั้ง ComfyUI

ขั้น 1 ดาวน์โหลด ComfyUI Portable จาก github.com/comfyanonymous/ComfyUI/releases เลือกไฟล์ ComfyUI_windows_portable_nvidia.7z ขนาดราว 1.5 GB

ขั้น 2 extract ไปยังที่ที่ต้องการ เช่น C:ComfyUI พื้นที่หลัง extract ราว 4 GB

ขั้น 3 ดับเบิลคลิก run_nvidia_gpu.bat รอจนเห็น “Starting server” ใน command line

ขั้น 4 เปิด browser ไปที่ http://127.0.0.1:8188 จะเห็นหน้า canvas

ขั้น 5 ติดตั้ง ComfyUI Manager เพื่อจัดการ custom node และโมเดล

cd C:\\ComfyUI\\ComfyUI_windows_portable\\ComfyUI\\custom_nodes
git clone <https://github.com/ltdrdata/ComfyUI-Manager>

restart ComfyUI หลังจากนั้น เมนู Manager จะปรากฏมุมขวาบน

ขั้น 6 ดาวน์โหลดโมเดลผ่าน Manager → Model Manager เลือกที่ต้องการคลิก install ระบบจะวางในโฟลเดอร์ถูกต้องให้

โมเดลพื้นฐานที่ควรมี — Flux Dev fp8 สำหรับสร้างภาพ, Wan 2.2 I2V สำหรับขยับภาพเป็นคลิป, VAE และ text encoder ที่มากับโมเดล

ถ้าต้องการ identity lock (หน้าคนเดียวกันทุกภาพ) เพิ่ม PuLID v0.9.1 และ custom node ComfyUI-PuLID-Flux-Enhanced fork ของ sipie800 (fork อื่น crash บน Comfy 0.12.x)


ส่วนที่ 2 — ติดตั้ง Remotion

ขั้น 1 สร้างโปรเจกต์ใหม่ เปิด terminal แล้วรัน

npm init video

ตอบคำถามตามที่ระบบถาม เลือก template “Hello World”

ขั้น 2 เข้าโฟลเดอร์ ติดตั้ง dependency

cd my-video
npm install

ขั้น 3 เปิด preview studio

npm start

browser จะเปิดที่ http://localhost:3000 เห็น Remotion Studio พร้อมใช้งาน

ขั้น 4 render วิดีโอ

npx remotion render src/index.ts MyVideo out.mp4

ใช้ Remotion compose คลิปจาก ComfyUI ทำแบบนี้ — นำไฟล์ mp4 ที่ได้จาก ComfyUI วางในโฟลเดอร์ public/ ของโปรเจกต์ Remotion แล้วเรียกใช้ผ่าน component <Video> พร้อมเขียน timing/caption เป็น React

import { Video, AbsoluteFill, staticFile } from 'remotion';
export const MyShot = () => (
<AbsoluteFill>
<Video src={staticFile('shot-01.mp4')} />
<h1 style={{position: 'absolute', top: 50, color: 'white'}}>
LOW ANGLE
</h1>
</AbsoluteFill>
);

ส่วนที่ 3 — ติดตั้ง HyperFrames

HyperFrames ใช้ Node.js เหมือน Remotion ติดตั้งง่ายกว่าเพราะมี CLI สำเร็จรูป

ขั้น 1 สร้างโปรเจกต์ใหม่

npx hyperframes init my-composition
cd my-composition

ขั้น 2 preview ในเบราว์เซอร์

npx hyperframes preview

ขั้น 3 render เป็นวิดีโอ

npx hyperframes render

จุดแข็งที่ HyperFrames มีให้และ Remotion ไม่มีในตัว — Kokoro สำหรับสร้างเสียงพากย์จากข้อความ, Whisper สำหรับ transcribe เสียงเป็น caption อัตโนมัติ, u2net สำหรับลบ background ทำ overlay โปร่งใส ทั้งหมดทำงาน local

เลือกใช้ตามงาน — Remotion สำหรับ composition ที่ใช้ React, HyperFrames สำหรับ composition ที่ใช้ HTML/CSS หรือต้องการ asset preprocessing ในตัว


ลำดับการเรียนที่แนะนำ

ติดตั้งทีละตัว ไม่ติดสามตัวพร้อมกัน

รอบ 1 — ติดตั้ง ComfyUI + Flux ฝึกสร้างภาพนิ่ง 50 ภาพจนคุ้นมือ

รอบ 2 — เพิ่ม Wan I2V ฝึกขยับภาพเป็นคลิป 3-5 วินาที

รอบ 3 — ติดตั้ง Remotion compose คลิปจาก ComfyUI เป็นวิดีโอ 30 วินาที

รอบ 4 — เพิ่ม HyperFrames ลอง composition ที่มี caption + audio

ลำดับนี้ป้องกัน overwhelm ค่อยๆ สะสมความเข้าใจในแต่ละ layer ของ stack


วิธีสั่งงาน — Prompt, Slash Command และทำให้ทำงานเองข้ามคืน

ติดตั้ง 3 stack แล้วยังไม่จบ จุดที่ทำให้ pipeline นี้ใช้งานได้จริงคือชั้น orchestration ที่อยู่บน ComfyUI/Remotion/HyperFrames อีกที — สั่งครั้งเดียวจบ ระบบรันต่อจนเสร็จ 9 ชั่วโมงข้ามคืนโดยไม่ต้องนั่งเฝ้า


โปรแกรมการใช้งานที่แนะนำ

Claude Code เป็นตัวที่เหมาะที่สุดในตอนนี้ — มี Bash tool, Background task, File system access, MCP server integration ครบในตัว ติดตั้งจาก claude.com/claude-code มี subscription รายเดือน $20 ก็ใช้ได้เต็มฟีเจอร์

ทางเลือกอื่น Cursor, Cline, หรือเขียน Python script ของตัวเองเรียก ComfyUI ตรงๆ ก็ได้ แต่จะขาด autonomous loop ที่ Claude Code มี


ComfyUI HTTP API คือกุญแจ

ComfyUI เปิด HTTP API ที่ http://127.0.0.1:8188 อยู่แล้วโดยอัตโนมัติ ใช้ 3 endpoint หลัก

  • POST /prompt — ส่ง workflow JSON ให้ ComfyUI รัน
  • GET /history/{prompt_id} — เช็คสถานะ
  • GET /view — ดึงไฟล์ผลลัพธ์

Python wrapper สั้นๆ ที่ใช้ได้กับทุก workflow

import requests, json, time
with open("workflow.json") as f:
workflow = json.load(f)
# inject parameter ลงใน node ที่ต้องการ
workflow["6"]["inputs"]["text"] = "your prompt here"
workflow["10"]["inputs"]["seed"] = 12345
# submit
r = requests.post("<http://127.0.0.1:8188/prompt>", json={"prompt": workflow})
prompt_id = r.json()["prompt_id"]
# รอจนเสร็จ
while True:
h = requests.get(f"<http://127.0.0.1:8188/history/{prompt_id}>").json()
if prompt_id in h:
break
time.sleep(5)
print("done:", h[prompt_id]["outputs"])

ใน ComfyUI canvas — กด Save (API Format) จะได้ workflow.json พร้อมใช้ ไม่ต้องเขียน JSON เอง


Slash Command ที่ Claude Code มีให้ใช้

/goal — โหมด autonomous Claude วาง plan + execute เอง รายงานเป็นระยะ ใช้สำหรับงาน multi-step ที่กินเวลา เช่น “ทำคลิป v9 15 ช็อต ตาม pipeline เดิม”

/loop — รัน command ซ้ำตามจังหวะที่กำหนด ใช้กับงาน polling เช่น check status ของ Wan render ทุก 5 นาที

/loop dynamic — Claude เลือกจังหวะเอง ใช้กับงาน wait-for-completion ที่ไม่รู้ว่าจะนานแค่ไหน

นอกจาก built-in command คุณยังสร้าง custom skill ของตัวเองได้ — เขียน SKILL.md วางใน ~/.claude/skills/ Claude จะ load อัตโนมัติทุกห้อง


ตัวอย่าง skill ที่ตั้งชื่อให้สั้น

  • /gen-keyframes — รับ shot list → รัน Flux+PuLID gen ทุก keyframe
  • /run-wan — เก็บ keyframes ที่มี → submit Wan I2V serial
  • /upscale-batch — รัน Real-ESRGAN x4 ทุกคลิปในโฟลเดอร์
  • /compose-reel — ใส่ caption + concat → final mp4

Workflow Autonomous Overnight

ตัวอย่างPromptที่ใช้งานจริง — พิมพ์เข้าไปประโยคเดียว

/goal ทำคลิป ให้ข้อมูลวิธีการประหยัด Token ใน Claude 10 วิธี โดยใช้หน้าผู้หญิงคนนี้ ( แนบรูปเข้าไปด้วย )
pipeline: Flux+PuLID keyframes → smoke test → Wan I2V 1280×720 49f
→ Real-ESRGAN x4 → compose ใส่ caption EN/TH ทุกช็อต
ทำจนเสร็จและรายงานผลตลอด

Claude Code จะทำ:

  1. สร้าง shots_v9.json จาก prompt list ที่ได้
  2. รัน Flux+PuLID script (~15 นาที) ผ่าน Bash tool
  3. หยุดทำ smoke test — เปิด PNG ทุกภาพดู ใช้ vision ตรวจว่ามุมกล้องตรงไหม ภาพไหนพลาด — แก้ prompt + re-gen
  4. spawn background task รัน Wan I2V serial 15 ช็อต (~8.5 ชม.)
  5. ระหว่างรอ — รายงานสถานะทุก 30 นาที โดยไม่ปลุกคุณ
  6. Wan เสร็จ → รัน Real-ESRGAN batch อัตโนมัติ
  7. compose ffmpeg + ใส่ caption
  8. copy ไฟล์ลง Downloads + เปิด File Explorer
  9. รายงานเช้ามา — ไฟล์อยู่ที่ไหน ใช้เวลาไป กี่ชั่วโมง มีปัญหาอะไรไหม

ตื่นมาเช้าได้คลิปพร้อมโพสต์


สิ่งที่ทำให้ autonomous เป็นจริง ไม่ใช่ทฤษฎี

  • Watchdog script ตรวจ ComfyUI ค้าง + auto-restart ทุก 30 นาที (Wan render นานๆ บางครั้ง process แฮง)
  • Logging ทุกขั้น เขียน timestamp + parameter + output path ลงไฟล์ ถ้าตื่นมาเจอ error จะ trace ย้อนได้ทันที
  • Idempotent scripts ทุก script เช็คก่อนว่าไฟล์ output มีอยู่หรือยัง ถ้ามีข้าม — รัน script ซ้ำได้โดยไม่ลบของเดิม
  • Background task ของ Claude Code ใช้ flag run_in_background รัน Python script ค้างไว้ Claude ไม่ต้องนั่งเฝ้า process Claude จะถูก notify เมื่อ task เสร็จ

สิ่งที่ทำไม่ได้ (ยัง)

  • เรนเดอร์ระหว่างปิดเครื่อง — ต้องเปิดเครื่องเปิด ComfyUI ค้างไว้ ใช้ระบบ Sleep ไม่ได้ (GPU ดับ)
  • รันข้าม PC — ComfyUI ผูกกับเครื่องเดียว ถ้าอยากใช้หลายเครื่องต้องตั้ง ComfyUI cluster เพิ่ม
  • อธิบาย error ที่ ComfyUI throw — Claude อ่าน log ได้แต่บางครั้งต้อง intervene เอง

หากอ่านทั้งหมดแล้วไม่เข้าใจ ไม่เป็นไร Copy Link website นี้แล้วโยนไปให้ Claude อ่านและบอกให้ทำตามนี้


genaispace.net : A Space to learn Generative AI Together

รับเทรนนิ่งองค์กรเกี่ยวกับการใช้ Generative AI เพื่อพัฒนาทักษะของพนักงาน เป็นองค์กร,บริษัท,กลุ่ม,เดี่ยว ด้วยประสบการณ์กว่า 3 ปี ผ่านองค์กรใหญ่ๆมากกว่า 60 แห่งและพนักงานกว่า 3,500 คน

Leave a Reply

Discover more from GenAI Space

Subscribe now to keep reading and get access to the full archive.

Continue reading