| 阶段 | 环节 | 谁来做 | 落地脚本 |
|---|---|---|---|
| 0 | 接收参考视频(本地 / 直链 / 平台分享链接) | 你提供 | — |
| 1 | 抽帧 + 探测比例时长 + 可选转录 → 反推提示词骨架 | 自动 | extract_frames.py |
| 2 | 收集商品图 + 卖点 + 是否保留原文案 | 你提供 | — |
| 3 | 代入商品拼最终提示词(必须你确认) | 我起草,你拍板 | — |
| 4 | 调 Agnes 创建任务并轮询下载(需 API Key) | 需你给 Key | generate_video.py / retry_poll.py |
| 5 | 加字幕 + 背景音乐(确认原片后做) | 你选 BGM / 文案 | add_subtitle_bgm.py |
你有一条抖音竖屏视频:一个陶瓷咖啡杯在厨房台面上缓缓旋转。你想换成自己的不锈钢保温杯,比例 / 时长 / 镜头跟原视频一模一样,最后加一句卖点字幕和一段轻音乐。
python "/skills/refvideo-product-gen/scripts/extract_frames.py" ^
--input "参考视频.mp4" --output-dir ./ref_analysis --num-frames 10 --transcribe
脚本会:定位 / 下载视频 → ffprobe 探测比例与时长 → 均匀抽 10 帧 →(可选)Whisper 转录口播。输出 JSON 摘要,含 ratio、mapped_num_frames、mapped_frame_rate、帧图路径、转录文案。我逐帧看图后,按「八维度」(主体/动作/场景/镜头/光线/风格/比例/时长)写出反推骨架 reference_prompt 给你看。
我按模板把主体换成保温杯,给你完整展示:生成模式(有公网图 → ti2vid 图生视频,外观更保真)、最终 prompt、反向提示词(必含 subtitles, captions, watermark, logo text)、宽高 / 帧数 / 帧率(严格沿用第 1 步探测值)。确认后才会消耗 API 额度开始生成。
python "/skills/refvideo-product-gen/scripts/generate_video.py" ^
--prompt "The stainless tumbler performs a slow elegant rotation on a wooden kitchen counter, warm morning sunlight, smooth cinematic orbit shot, cozy lifestyle advertisement style" ^
--image "https://xxx/cup.png" --mode ti2vid ^
--width 768 --height 1152 --num-frames 121 --frame-rate 24 ^
--negative-prompt "subtitles, captions, text overlay, watermark, logo text, blurry, distorted hands" ^
--api-key "你的Agnes Key" --output-dir ./output
脚本自动轮询并下载成片到 output/ecom_video_<id>.mp4,同时保存 <id>.json 元数据。生成的无字幕原片先给你预览。
GET /agnesapi 轮询常被 Cloudflare 返回 403。遇到时别反复重试——先记下脚本打印的 video_id,换网络 / 开 VPN 后跑:python "/skills/refvideo-product-gen/scripts/retry_poll.py" --from-file output/ecom_video_<id>.json E:/背景音乐1.MP3;字幕文案给一句卖点即可。我烧字幕 + 混音输出 final_product_video.mp4。python "/skills/refvideo-product-gen/scripts/add_subtitle_bgm.py" ^
--input output/ecom_video_<id>.mp4 ^
--subtitle-text "一键开盖,1L大容量,保温12小时" ^
--bgm "E:/背景音乐1.MP3" --bgm-volume 0.3 ^
--output output/final_product_video.mp4
| 比例 | width | height | 适用 |
|---|---|---|---|
| 9:16 | 768 | 1152 | 竖版短视频(抖音/快手/视频号/Reels) |
| 16:9 | 1152 | 768 | 横版演示 |
| 1:1 | 768 | 768 | 方形信息流 |
| 4:3 | 1024 | 768 | 传统横版 |
| 3:4 | 768 | 1024 | 竖版产品展示 |
| 时长 | num_frames | frame_rate |
|---|---|---|
| ~3s | 81 | 24 |
| ~5s | 121 | 24 |
| ~10s | 241 | 24 |
| ~18s | 441 | 24 |
| ~29s | 441 | 15 |
| ~37s | 441 | 12 |
num_frames 必须 <=441 且满足 8n+1(81/121/241/441),否则 API 返回 400。
分阶段确认不能省: 反推展示 → 商品信息 → 提示词确认 → 生成 → 加字幕/BGM,任一步都要你拍板;生成后必须先看原片,再说要不要加字幕。
extract_frames.py 探测值为准,不擅自改。detected_language 仅供参考)。| 依赖 | 本机状态 |
|---|---|
| ffmpeg / ffprobe | 7.1,已在 PATH ✓(抽帧 / 烧字幕 / 混音依赖) |
| requests | 已装在隔离 venv(2.34.2)✓ |
| Whisper(转录,可选) | 未装则跳过转录并提示,不影响抽帧 |
| yt-dlp(平台链接下载,可选) | 未装则提示你把视频下到本机再上传 |
| 脚本位置 |