AI 비디오 생성기 — 숏폼 콘텐츠 파이프라인은(는) 무엇을 하나요?
개요
AI를 사용하여 숏폼 비디오(틱톡, 유튜브 쇼츠, 인스타그램 릴스) 제작의 모든 단계를 자동화합니다: 주제 연구, 스크립트 작성, 텍스트 음성 변환, 스톡 푸티지 매칭, 자막 생성 및 최종 조립. MoneyPrinterTurbo(53k+ 스타)에서 영감을 받았습니다.
지침
1단계: 환경 설정
pip install anthropic openai requests moviepy pydub whisperx srt
sudo apt install ffmpeg # Linux — 또는: brew install ffmpeg (macOS)
필요한 API 키: Anthropic 또는 OpenAI(스크립트), ElevenLabs 또는 OpenAI TTS(음성), Pexels(무료 스톡 푸티지).
2단계: AI 스크립트 작성
import anthropic
def generate_script(topic, duration_seconds=45):
"""숏폼 콘텐츠에 최적화된 비디오 스크립트를 생성합니다."""
client = anthropic.Anthropic()
prompt = f"""다음 주제에 대한 {duration_seconds}초 비디오 스크립트를 작성하세요: {topic}
형식:
HOOK (처음 3초): 스크롤을 멈추게 하는 놀라운 문장이나 질문
BODY (본문): 각각 1-2문장으로 구성된 3-5개의 강력한 사실 또는 포인트
CTA (마지막 5초): 행동 유도 — 팔로우, 좋아요, 댓글
규칙:
- 대화체, 복잡한 문장 금지
- 각 문장은 별도 줄에 작성
- 약 {duration_seconds * 2.5:.0f} 단어 ({duration_seconds}초, 분당 150단어 기준)
- 강력한 단어 사용: 비밀, 충격적, 아무도 알려주지 않는, 실제로
- 이모지나 해시태그 금지 — 이것은 음성 해설 스크립트입니다
"""
response = client.messages.create(
model="claude-sonnet-4-20250514", max_tokens=500,
messages=[{"role": "user", "content": prompt}]
)
return response.content[0].text
3단계: 텍스트 음성 변환(TTS) 나레이션
import requests, os
def generate_voice_elevenlabs(text, output_path='narration.mp3'):
"""ElevenLabs를 사용하여 음성 해설을 생성합니다."""
url = "https://api.elevenlabs.io/v1/text-to-speech/21m00Tcm4TlvDq8ikWAM"
headers = {"xi-api-key": os.environ["ELEVENLABS_API_KEY"], "Content-Type": "application/json"}
data = {"text": text, "model_id": "eleven_turbo_v2_5",
"voice_settings": {"stability": 0.5, "similarity_boost": 0.75}}
response = requests.post(url, json=data, headers=headers)
with open(output_path, 'wb') as f:
f.write(response.content)
return output_path
def generate_voice_openai(text, output_path='narration.mp3'):
"""OpenAI TTS를 사용하여 음성 해설을 생성합니다 (더 저렴한 대안)."""
from openai import OpenAI
client = OpenAI()
response = client.audio.speech.create(model="tts-1-hd", voice="onyx", input=text)
response.stream_to_file(output_path)
return output_path
4단계: 스톡 푸티지 선택
def search_pexels_videos(query, count=5):
"""Pexels에서 세로 방향의 스톡 비디오 클립을 검색합니다."""
url = "https://api.pexels.com/videos/search"
headers = {"Authorization": os.environ["PEXELS_API_KEY"]}
params = {"query": query, "per_page": count, "orientation": "portrait", "size": "medium"}
response = requests.get(url, headers=headers, params=params)
videos = response.json().get('videos', [])
results = []
for v in videos:
files = sorted(v['video_files'], key=lambda x: x.get('height', 0), reverse=True)
hd = next((f for f in files if f.get('height', 0) >= 720), files[0])
results.append({'id': v['id'], 'url': hd['link'], 'duration': v['duration']})
return results
5단계: 자막 생성
def generate_subtitles(audio_path, output_srt='subtitles.srt'):
"""WhisperX를 사용하여 단어 수준의 자막을 생성합니다."""
import whisperx, srt
from datetime import timedelta
model = whisperx.load_model("base", device="cpu")
audio = whisperx.load_audio(audio_path)
result = model.transcribe(audio)
align_model, metadata = whisperx.load_align_model(language_code="en")
aligned = whisperx.align(result["segments"], align_model, metadata, audio)
subs = []
words = [w for seg in aligned["segments"] for w in seg.get("words", [])]
for i in range(0, len(words), 4):
group = words[i:i + 4]
if not group: continue
start = timedelta(seconds=group[0].get('start', 0))
end = timedelta(seconds=group[-1].get('end', 0))
text = ' '.join(w['word'] for w in group)
subs.append(srt.Subtitle(index=len(subs)+1, start=start, end=end, content=text))
with open(output_srt, 'w') as f:
f.write(srt.compose(subs))
return output_srt
6단계: FFmpeg를 사용한 비디오 조립
import subprocess
def assemble_video(clips, narration, subtitles, output='final.mp4'):
"""최종 비디오 조립: 클립 연결, 나레이션 및 자막 추가."""
concat_list = 'concat_list.txt'
with open(concat_list, 'w') as f:
for clip in clips:
f.write(f"file '{clip}'\n")
subprocess.run([
'ffmpeg', '-y', '-f', 'concat', '-safe', '0', '-i', concat_list,
'-vf', 'scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920',
'-c:v', 'libx264', '-preset', 'fast', '-an', 'temp_video.mp4'
], check=True)
subtitle_filter = (f"subtitles={subtitles}:force_style='"
"FontName=Arial,FontSize=18,PrimaryColour=&H00FFFFFF,"
"OutlineColour=&H00000000,Outline=2,Bold=1,Alignment=2'")
subprocess.run([
'ffmpeg', '-y', '-i', 'temp_video.mp4', '-i', narration,
'-vf', subtitle_filter, '-c:v', 'libx264', '-c:a', 'aac',
'-shortest', output
], check=True)
return output
7단계: 전체 파이프라인
def generate_video(topic, output_dir='./output'):
"""완전한 파이프라인: 주제 -> 완성된 비디오."""
import os
os.makedirs(output_dir, exist_ok=True)
script = generate_script(topic)
narration = generate_voice_elevenlabs(script, f'{output_dir}/narration.mp3')
keywords = topic.split()[:3]
videos = search_pexels_videos(' '.join(keywords), count=3)
clips = []
for i, v in enumerate(videos):
path = f'{output_dir}/clip_{i}.mp4'
requests.get(v['url'], stream=True) # 클립 다운로드
clips.append(path)
subs = generate_subtitles(narration, f'{output_dir}/subs.srt')
return assemble_video(clips, narration, subs, f'{output_dir}/final.mp4')
예제
예제 1: 기술 팁 비디오 배치 생성
크리에이터가 한 번의 실행으로 틱톡용 기술 테마 숏폼 비디오 5개를 제작합니다:
topics = [
"아무도 말하지 않는 AI 도구",
"무료로 사용하기에 죄책감 드는 앱",
"당신의 마음을 사로잡을 웹사이트",
"모든 학생이 알아야 할 무료 AI 도구",
"50달러 미만으로 내 인생을 바꾼 테크 기기"
]
for topic in topics:
output = generate_video(topic, output_dir=f'./output/{topic[:30]}')
print(f"비디오 준비 완료: {output}")
# 각 비디오: ~45초, 세로 1080x1920, 자막 및 나레이션 포함
# 총 비용: ~$0.25 (비디오당 $0.05 x 5) ElevenLabs + Claude Sonnet 사용
예제 2: 유튜브용 일일 금융 쇼츠
한 금융 채널이 트렌딩 머니 주제로 일일 쇼츠 업로드를 자동화합니다:
import schedule
def daily_finance_video():
topic = "2025년에 실제로 효과가 있는 3가지 패시브 인컴 아이디어"
script = generate_script(topic, duration_seconds=55)
# 스크립트 출력:
# HOOK: "이것들을 몰라서 매일 돈을 잃고 있습니다."
# BODY: 1. 주문형 인쇄 스토어 ($500-2k/월)
# 2. AI 생성 콘텐츠 라이선싱 ($300-1k/월)
# 3. 배당 ETF 스태킹 ($200-800/월 패시브)
# CTA: "아무도 말해주지 않는 돈 관련 팁을 위해 팔로우하세요."
narration = generate_voice_openai(script, './daily/narration.mp3')
videos = search_pexels_videos("money finance investing", count=4)
# 돈/차트/라이프스타일 푸티지의 세로 클립 4개 다운로드
# 굵은 흰색 자막과 함께 55초 쇼츠로 조립
final = assemble_video(['./daily/clip_0.mp4', './daily/clip_1.mp4'],
narration, './daily/subs.srt', './daily/final.mp4')
schedule.every().day.at("08:00").do(daily_finance_video)
지침
- 저작권 존중 — 로열티 프리 스톡 푸티지(Pexels, Pixabay) 또는 자신의 콘텐츠만 사용
- AI 사용 공개 — YouTube와 TikTok은 AI 생성 콘텐츠 공개를 요구합니다
- 게시 전 검토 — 항상 최종 비디오를 시청하세요. AI 스크립트에는 부정확성이 포함될 수 있습니다
- 처음 3초 최적화 — 후크가 시청자의 이탈 여부를 결정합니다
- 여러 음성 테스트 — ElevenLabs는 수십 가지 음성을 제공합니다. 자신의 분야에 맞는 음성을 찾으세요
- 성과 모니터링 — 조회수, 유지율, 클릭률을 추적하여 콘텐츠 스타일을 반복 개선하세요
참고 자료
- MoneyPrinterTurbo — 원본 영감 (53k 스타)
- Pexels API — 무료 스톡 비디오
- ElevenLabs — 사실적인 텍스트 음성 변환
- WhisperX — 단어 수준 자막 정렬