耳语视频转录解决方法
- 作者仓库星标 0
- 作者仓库 skills-registry
- 领域
- 数据
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @tomevault-io · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- Python
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
步骤 1 — 使用 ffmpeg 提取音频
标志说明: `-vn` — 无视频流 `-acodec pcm_s16le` — 16 位 PCM 音频(Whisper 首选) `-ar 16000` — 16kHz 采样率(Whisper 的本机速率) `-ac 1` — 单声道(更适合语音识别)
第 2 步 — 使用 Fast-Whisper 转录 WAV
中文模型尺寸指南:`tiny` — 最快,CPU 实时性约为 3 倍;可接受的精度 `medium` — 精度更高,但速度较慢 `large-v3-turbo` — 最佳精度;重得多
第 3 步 — 将成绩单保存到文件
始终写入 JSON 文件而不是保存在内存中:
# Whisper Video Transcription Workaround
## Problem
When running `whisper video.mp4` directly, the process may:
- Appear to run (PID exists, CPU may be active)
- But output dir stays empty even after many minutes
- Eventually time out or get stuck at ~33-43% "downloading/decoding"
This happens because the Whisper CLI tries to decode the video container internally, and certain video streams (especially DASH/m3u8 segmented video from YouTube downloads) cause the decoder to stall.
## Solution: Extract audio first, then transcribe
### Step 1 — Extract audio with ffmpeg
```bash
ffmpeg -i "video.mp4" -vn -acodec pcm_s16le -ar 16000 -ac 1 /tmp/audio.wav -y
```
Flags explained:
- `-vn` — no video stream
- `-acodec pcm_s16le` — 16-bit PCM audio (Whisper prefers)
- `-ar 16000` — 16kHz sample rate (Whisper's native rate)
- `-ac 1` — mono (better for speech recognition)
- `-y` — overwrite without asking
### Step 2 — Transcribe the WAV with faster-whisper
```python
from faster_whisper import WhisperModel
model = WhisperModel("tiny", device="cpu", compute_type="int8")
segments, info = model.transcribe(
"/tmp/audio.wav",
language="zh",
vad_filter=True,
vad_parameters=dict(min_silence_duration_ms=800)
)
results = [{"start": round(s.start, 2), "end": round(s.end, 2), "text": s.text.strip()} for s in segments]
```
Model size guide for Chinese:
- `tiny` — fastest, ~3x realtime on CPU; acceptable accuracy
- `medium` — better accuracy but slower
- `large-v3-turbo` — best accuracy; much heavier
### Step 3 — Save transcript to file
Always write to a JSON file rather than holding in memory:
```python
import json
with open("/tmp/transcript.json", "w", encoding="utf-8") as f:
json.dump({"segments": results, "language": info.language}, f, ensure_ascii=False, indent=2)
```
## Verification checklist
- [ ] Audio WAV was created (`ls -lh /tmp/audio.wav`)
- [ ] faster-whisper started logging segment output
- [ ] JSON file written with non-empty segments array
- [ ] Transcript language matches expected language
- [ ] Total duration of last segment ≈ video duration
## Why this works
ffmpeg's audio decoding is battle-tested and handles problematic streams gracefully. Whisper's audio decoder (even faster-whisper) can get confused by AV1 video streams in MP4 containers downloaded via yt-dlp (DASH format). Extracting to clean PCM WAV sidesteps the issue entirely.
## Known limitations
- The tiny model makes more transcription errors than medium/large — review before publishing
- Very long audio (>1hr) may still be slow on CPU; consider splitting with `ffmpeg -ss 0 -t 3600 -i audio.wav part1.wav`
---
> Source: [davidtoby/agent-skills](https://github.com/davidtoby/agent-skills) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->
章节与文件索引
按说明文件中的顺序排列。
问题
步骤 1 — 使用 ffmpeg 提取音频
第 2 步 — 使用 Fast-Whisper 转录 WAV
第 3 步 — 将成绩单保存到文件
验证清单
文件/命令 -> whisper video.mp4 · -vn · -acodec pcm_s16le · -ar 16000 · -ac 1 · tiny · medium · large-v3-turbo
内容校验值 -> 4ffcb6cc94a8
当前原文的自动摘译,尚未人工审校。
问题
当直接运行
whisper video.mp4时,该进程可能会: 看起来正在运行(PID 存在,CPU 可能处于活动状态) 但输出目录即使在几分钟后仍为空 最终超时或卡在 ~33-43%“下载/解码” 发生这种情况是因为 Whisper CLI 尝试在内部解码视频容器,并且某些视频流(尤其是来自 YouTube 下载的 DASH/m3u8 分段视频)导致解码器停止。验证清单
[ ] 音频 WAV 已创建 (
ls -lh /tmp/audio.wav) [ ] 更快的耳语开始记录片段输出 [ ] 使用非空片段数组编写的 JSON 文件 [ ] 转录语言与预期语言匹配 [ ] 最后片段的总持续时间 ≈ 视频持续时间