Video Clip Assistant
影片自動剪輯助手。基於 FFmpeg,提供影片剪切、字幕生成、短影片匯出等功能。
核心能力
- 時間軸剪切 — 按時間戳提取片段
- 關鍵詞切片 — 基於 ASR 字幕找到關鍵詞對應片段
- 字幕燒錄 — SRT 字幕壓制到影片
- 短影片匯出 — 裁切為 9:16/1:1/16:9 多比例
- 精華提取 — 自動從長影片提取高光片段
快速開始
按時間剪切
python3 scripts/cut_video.py --input video.mp4 --start 10 --duration 30 --output clip.mp4
提取多段
python3 scripts/cut_video.py --input video.mp4 --segments "0-30,60-90,120-150" --output ./clips/
燒錄字幕
python3 scripts/burn_subtitles.py --input video.mp4 --srt subs.srt --output subtitled.mp4
匯出短影片
python3 scripts/export_social.py --input video.mp4 --format vertical --duration 60 --output shorts/
腳本說明
scripts/cut_video.py
按時間軸剪切影片。
python3 scripts/cut_video.py \
--input <影片檔案> \
--start <秒> \
--duration <秒> \
[--segments "0-30,60-90"] \
--output <輸出>
scripts/burn_subtitles.py
將 SRT 字幕燒錄到影片。
python3 scripts/burn_subtitles.py \
--input <影片> \
--srt <字幕檔案> \
--output <輸出>
支援字幕位置、字型大小、顏色自訂。
scripts/export_social.py
匯出為多平台適配格式。
python3 scripts/export_social.py \
--input <影片> \
--format <vertical|square|horizontal> \
--duration <秒> \
--output <輸出目錄>
| 格式 | 比例 | 用途 |
|---|---|---|
| vertical | 9:16 | 抖音/快手/小紅書 |
| square | 1:1 | |
| horizontal | 16:9 | YouTube/B站 |
scripts/extract_highlights.py
從長影片自動提取精華片段。
python3 scripts/extract_highlights.py \
--input <影片> \
--num-clips <片段數> \
--min-duration <最小秒數> \
--output <輸出目錄>
使用場景檢測演算法定位精彩切換點。
scripts/generate_subtitles.py
產生 SRT 字幕檔案(需要 ASR 服務)。
python3 scripts/generate_subtitles.py \
--input <影片> \
--provider <whisper|funclip> \
--output <字幕.srt>
典型工作流
工作流1:從會議錄影提取3個精華片段
# 1. 剪切3個片段
python3 scripts/cut_video.py \
--input meeting.mp4 \
--segments "300-360,720-780,1200-1260" \
--output ./clips/
# 2. 分別匯出為抖音格式
for f in ./clips/*.mp4; do
python3 scripts/export_social.py \
--input "$f" \
--format vertical \
--output ./shorts/
done
工作流2:給影片加上字幕
# 1. 產生字幕
python3 scripts/generate_subtitles.py \
--input video.mp4 \
--provider whisper \
--output video.srt
# 2. 燒錄字幕
python3 scripts/burn_subtitles.py \
--input video.mp4 \
--srt video.srt \
--output subtitled.mp4
工作流3:一鍵產生多個短影片
python3 scripts/export_social.py \
--input long_video.mp4 \
--format vertical \
--duration 60 \
--output ./shorts/
環境需求
- 必須:FFmpeg(
ffmpeg/ffprobe) - 可選:FunClip(阿里開源 ASR 影片剪輯)
- 可選:Whisper(本地或 API 模式)
安裝參考
# 安裝 FunClip(推薦)
pip install funclip
# 安裝 Whisper
pip install openai-whisper
# FFmpeg(已有)
which ffmpeg # 應回傳路徑