plugin: video-editing updated: 2026-01-20
Whisper를 사용한 트랜스크립션
OpenAI Whisper를 사용한 오디오/비디오 트랜스크립션을 위한 프로덕션 준비 패턴입니다.
시스템 요구 사항
설치 옵션
옵션 1: OpenAI Whisper (Python)
# macOS/Linux/Windows
pip install openai-whisper
# 확인
whisper --help
옵션 2: whisper.cpp (C++ - 더 빠름)
# macOS
brew install whisper-cpp
# Linux - 소스에서 빌드
git clone https://github.com/ggerganov/whisper.cpp
cd whisper.cpp && make
# Windows - 사전 빌드된 바이너리 사용 또는 cmake로 빌드
옵션 3: Insanely Fast Whisper (GPU 가속)
pip install insanely-fast-whisper
모델 선택
| 모델 | 크기 | VRAM | 정확도 | 속도 | 사용 사례 |
|---|---|---|---|---|---|
| tiny | 39M | ~1GB | 낮음 | 가장 빠름 | 빠른 미리보기 |
| base | 74M | ~1GB | 중간 | 빠름 | 초안 트랜스크립트 |
| small | 244M | ~2GB | 좋음 | 중간 | 일반 사용 |
| medium | 769M | ~5GB | 더 좋음 | 느림 | 품질 트랜스크립트 |
| large-v3 | 1550M | ~10GB | 최고 | 가장 느림 | 최종 프로덕션 |
권장 사항: 속도와 품질의 균형을 위해 small로 시작하세요. 최종 전달 시에는 large-v3를 사용하세요.
기본 트랜스크립션
OpenAI Whisper 사용
# 기본 트랜스크립션 (언어 자동 감지)
whisper audio.mp3 --model small
# 언어 및 출력 형식 지정
whisper audio.mp3 --model medium --language en --output_format srt
# 여러 출력 형식
whisper audio.mp3 --model small --output_format all
# 타임스탬프 및 단어 수준 타이밍 포함
whisper audio.mp3 --model small --word_timestamps True
whisper.cpp 사용
# 먼저 모델 다운로드
./models/download-ggml-model.sh base.en
# 트랜스크립션 수행
./main -m models/ggml-base.en.bin -f audio.wav -osrt
# 타임스탬프 포함
./main -m models/ggml-base.en.bin -f audio.wav -ocsv
출력 형식
SRT (SubRip Subtitle)
1
00:00:01,000 --> 00:00:04,500
Hello and welcome to this video.
2
00:00:05,000 --> 00:00:08,200
Today we'll discuss video editing.
VTT (WebVTT)
WEBVTT
00:00:01.000 --> 00:00:04.500
Hello and welcome to this video.
00:00:05.000 --> 00:00:08.200
Today we'll discuss video editing.
JSON (단어 수준 타이밍 포함)
{
"text": "Hello and welcome to this video.",
"segments": [
{
"id": 0,
"start": 1.0,
"end": 4.5,
"text": " Hello and welcome to this video.",
"words": [
{"word": "Hello", "start": 1.0, "end": 1.3},
{"word": "and", "start": 1.4, "end": 1.5},
{"word": "welcome", "start": 1.6, "end": 2.0},
{"word": "to", "start": 2.1, "end": 2.2},
{"word": "this", "start": 2.3, "end": 2.5},
{"word": "video", "start": 2.6, "end": 3.0}
]
}
]
}
트랜스크립션을 위한 오디오 추출
비디오를 트랜스크립션하기 전에 최적의 형식으로 오디오를 추출하세요:
# 오디오를 WAV로 추출 (16kHz, 모노 - Whisper에 최적)
ffmpeg -i video.mp4 -ar 16000 -ac 1 -c:a pcm_s16le audio.wav
# 보관용 고품질 WAV로 추출
ffmpeg -i video.mp4 -vn -c:a pcm_s16le audio.wav
# 압축된 MP3로 추출 (더 작지만 여전히 작동)
ffmpeg -i video.mp4 -vn -c:a libmp3lame -q:a 2 audio.mp3
타이밍 동기화
Whisper JSON을 FCP 타이밍으로 변환
import json
def whisper_to_fcp_timing(whisper_json_path, fps=24):
"""Whisper JSON 출력을 FCP 호환 타이밍으로 변환합니다."""
with open(whisper_json_path) as f:
data = json.load(f)
segments = []
for seg in data.get("segments", []):
segments.append({
"start_time": seg["start"],
"end_time": seg["end"],
"start_frame": int(seg["start"] * fps),
"end_frame": int(seg["end"] * fps),
"text": seg["text"].strip(),
"words": seg.get("words", [])
})
return segments
프레임 정확도 타이밍
# 정확한 프레임 수와 지속 시간 가져오기
ffprobe -v error -count_frames -select_streams v:0 \
-show_entries stream=nb_read_frames,duration,r_frame_rate \
-of json video.mp4
화자 분리
여러 화자가 있는 콘텐츠의 경우 pyannote.audio를 사용하세요:
pip install pyannote.audio
from pyannote.audio import Pipeline
pipeline = Pipeline.from_pretrained("pyannote/[email protected]")
diarization = pipeline("audio.wav")
for turn, _, speaker in diarization.itertracks(yield_label=True):
print(f"{turn.start:.1f}s - {turn.end:.1f}s: {speaker}")
배치 처리
#!/bin/bash
# 디렉토리의 모든 비디오를 트랜스크립션합니다.
MODEL="small"
OUTPUT_DIR="transcripts"
mkdir -p "$OUTPUT_DIR"
for video in *.mp4 *.mov *.avi; do
[[ -f "$video" ]] || continue
base="${video%.*}"
# 오디오 추출
ffmpeg -i "$video" -ar 16000 -ac 1 -c:a pcm_s16le "/tmp/${base}.wav" -y
# 트랜스크립션
whisper "/tmp/${base}.wav" --model "$MODEL" \
--output_format all \
--output_dir "$OUTPUT_DIR"
# 임시 오디오 정리
rm "/tmp/${base}.wav"
echo "트랜스크립션 완료: $video"
done
품질 최적화
정확도 향상
- 트랜스크립션 전 노이즈 감소:
ffmpeg -i noisy_audio.wav -af "highpass=f=200,lowpass=f=3000,afftdn=nf=-25" clean_audio.wav
- 언어 힌트 사용:
whisper audio.mp3 --language en --model medium
- 컨텍스트를 위한 초기 프롬프트 제공:
whisper audio.mp3 --initial_prompt "Technical discussion about video editing software."
성능 팁
- GPU 가속 (사용 가능한 경우):
whisper audio.mp3 --model large-v3 --device cuda
- 긴 비디오의 경우 청크로 처리:
# 10분 청크로 오디오 분할
# 각 청크 트랜스크립션
# 시간 오프셋 조정으로 결과 병합
오류 처리
# 트랜스크립션 전 오디오 파일 검증
validate_audio() {
local file="$1"
if ffprobe -v error -select_streams a:0 -show_entries stream=codec_type -of csv=p=0 "$file" 2>/dev/null | grep -q "audio"; then
return 0
else
echo "오류: $file에서 오디오 스트림을 찾을 수 없습니다"
return 1
fi
}
# Whisper 설치 확인
check_whisper() {
if command -v whisper &> /dev/null; then
echo "Whisper 사용 가능"
return 0
else
echo "오류: Whisper가 설치되지 않았습니다. 실행: pip install openai-whisper"
return 1
fi
}
관련 스킬
- ffmpeg-core - 오디오 추출 및 전처리
- final-cut-pro - 트랜스크립트를 타이틀/마커로 가져오기