dsh-pf-stream 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +145 -33
- package/README.md +142 -30
- package/client.js +1156 -0
- package/icon.svg +18 -0
- package/lib/asr/catalog.d.ts +74 -0
- package/lib/asr/catalog.js +168 -0
- package/lib/asr/catalog.js.map +1 -0
- package/lib/asr/detect.d.ts +33 -0
- package/lib/asr/detect.js +117 -0
- package/lib/asr/detect.js.map +1 -0
- package/lib/asr/engine.d.ts +43 -0
- package/lib/asr/engine.js +143 -0
- package/lib/asr/engine.js.map +1 -0
- package/lib/asr/install.d.ts +56 -0
- package/lib/asr/install.js +317 -0
- package/lib/asr/install.js.map +1 -0
- package/lib/asr/verify.d.ts +22 -0
- package/lib/asr/verify.js +174 -0
- package/lib/asr/verify.js.map +1 -0
- package/lib/audio/acousticVad.d.ts +45 -0
- package/lib/audio/acousticVad.js +179 -0
- package/lib/audio/acousticVad.js.map +1 -0
- package/lib/audio/asrProviders.d.ts +51 -0
- package/lib/audio/asrProviders.js +251 -0
- package/lib/audio/asrProviders.js.map +1 -0
- package/lib/audio/asrRouter.d.ts +30 -0
- package/lib/audio/asrRouter.js +187 -0
- package/lib/audio/asrRouter.js.map +1 -0
- package/lib/audio/hallucinationGuard.d.ts +18 -0
- package/lib/audio/hallucinationGuard.js +97 -0
- package/lib/audio/hallucinationGuard.js.map +1 -0
- package/lib/audio/sidecar.d.ts +76 -0
- package/lib/audio/sidecar.js +362 -0
- package/lib/audio/sidecar.js.map +1 -0
- package/lib/audio/subtitleExtractor.d.ts +36 -0
- package/lib/audio/subtitleExtractor.js +218 -0
- package/lib/audio/subtitleExtractor.js.map +1 -0
- package/lib/audio/transcriptCache.d.ts +33 -0
- package/lib/audio/transcriptCache.js +126 -0
- package/lib/audio/transcriptCache.js.map +1 -0
- package/lib/audio/types.d.ts +136 -0
- package/lib/audio/types.js +10 -0
- package/lib/audio/types.js.map +1 -0
- package/lib/host/api.d.ts +23 -0
- package/lib/host/api.js +286 -0
- package/lib/host/api.js.map +1 -0
- package/lib/host/runtime.d.ts +167 -0
- package/lib/host/runtime.js +335 -0
- package/lib/host/runtime.js.map +1 -0
- package/lib/index.d.ts +229 -1
- package/lib/index.js +103 -2
- package/lib/index.js.map +1 -1
- package/lib/session/state.js +4 -0
- package/lib/session/state.js.map +1 -1
- package/lib/stage0/decoder.d.ts +1 -9
- package/lib/stage0/decoder.js +15 -45
- package/lib/stage0/decoder.js.map +1 -1
- package/lib/stage2/stateMachine.d.ts +4 -1
- package/lib/stage2/stateMachine.js +7 -1
- package/lib/stage2/stateMachine.js.map +1 -1
- package/lib/stage3/deterministicRouter.js +3 -3
- package/lib/stage3/deterministicRouter.js.map +1 -1
- package/lib/stage3/streamSampler.d.ts +9 -2
- package/lib/stage3/streamSampler.js +37 -16
- package/lib/stage3/streamSampler.js.map +1 -1
- package/lib/stage6/history.d.ts +2 -1
- package/lib/stage6/history.js +4 -1
- package/lib/stage6/history.js.map +1 -1
- package/lib/tool/handler.d.ts +9 -0
- package/lib/tool/handler.js +33 -3
- package/lib/tool/handler.js.map +1 -1
- package/lib/tool/schema.js +15 -2
- package/lib/tool/schema.js.map +1 -1
- package/lib/tool/streamCall.d.ts +11 -0
- package/lib/tool/streamCall.js +122 -9
- package/lib/tool/streamCall.js.map +1 -1
- package/lib/types.d.ts +9 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +17 -2
package/README.en.md
CHANGED
|
@@ -1,58 +1,170 @@
|
|
|
1
1
|
# dsh-pf-stream
|
|
2
2
|
|
|
3
|
-
[中文](README.md) | **English**
|
|
3
|
+
[中文](https://github.com/Weilv-D/dsh-pf-stream/blob/main/README.md) | **English**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Let the agent watch videos: adaptive sampling, plus the spoken lines.
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
8
|
+
|
|
9
|
+
- **See**: motion is recorded as it happens; the moment it settles, detail is captured. Any timestamp can be inspected at full resolution.
|
|
10
|
+
- **Hear**: subtitles are used when present; otherwise a transcription engine produces the speech and mounts it on the matching frames.
|
|
11
|
+
- **Optional setup**: video works without transcription; with it, videos that only have a voice track also work.
|
|
6
12
|
|
|
7
13
|
## Install
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
### 1. Install ffmpeg
|
|
16
|
+
|
|
17
|
+
The plugin decodes video with ffmpeg. Check that it runs:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
ffmpeg -version
|
|
21
|
+
ffprobe -version
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Both must print output. If not:
|
|
10
25
|
|
|
11
|
-
|
|
26
|
+
| OS | Command |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| Windows | `winget install Gyan.FFmpeg` |
|
|
29
|
+
| macOS | `brew install ffmpeg` |
|
|
30
|
+
| Ubuntu / Debian | `sudo apt install ffmpeg` |
|
|
12
31
|
|
|
13
|
-
|
|
32
|
+
Open a new terminal and check again. To keep it out of PATH, set `ffmpegPath` and `ffprobePath` in the plugin config.
|
|
33
|
+
|
|
34
|
+
### 2. Install the plugin in DSH
|
|
35
|
+
|
|
36
|
+
1. Open DSH and click **Plugins** in the left sidebar.
|
|
37
|
+
2. Find **Video understanding** (package `dsh-pf-stream`).
|
|
38
|
+
3. Open its detail page and switch it on (top right).
|
|
39
|
+
4. On first enable, a setup card appears on the detail page.
|
|
40
|
+
|
|
41
|
+
If it is not listed, use the install entry on the Plugins page to install `dsh-pf-stream` from npm, then return here.
|
|
42
|
+
|
|
43
|
+
You can also hand the install to the agent:
|
|
14
44
|
|
|
15
45
|
```text
|
|
16
|
-
Install the DSH plugin dsh-pf-stream
|
|
17
|
-
1. Install the latest
|
|
18
|
-
2. Check ffmpeg and ffprobe
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Linux: sudo apt install ffmpeg.
|
|
22
|
-
3. Call probe on a local video. A returned duration and resolution means success.
|
|
23
|
-
4. Report the plugin version, the ffmpeg location, and the check result.
|
|
46
|
+
Install the DSH plugin dsh-pf-stream:
|
|
47
|
+
1. Install the latest version from npm with the plugin manager; success means result applied;
|
|
48
|
+
2. Check ffmpeg and ffprobe; install them if missing (Windows: winget install Gyan.FFmpeg / macOS: brew install ffmpeg / Linux: sudo apt install ffmpeg);
|
|
49
|
+
3. Call probe on a local video; duration and resolution in the result means success;
|
|
50
|
+
4. Report the plugin version, ffmpeg location, and check results.
|
|
24
51
|
```
|
|
25
52
|
|
|
26
|
-
|
|
53
|
+
## First run: configure transcription
|
|
54
|
+
|
|
55
|
+
The transcription engine decides whether videos without subtitles get speech text. Without it, video still works; only the transcript is missing.
|
|
27
56
|
|
|
28
|
-
|
|
57
|
+
To open the settings: **Plugins in the left sidebar → Video understanding → the panel below the description**. Use the same path later to change settings.
|
|
29
58
|
|
|
30
|
-
|
|
31
|
-
winget install Gyan.FFmpeg # Windows
|
|
32
|
-
brew install ffmpeg # macOS
|
|
33
|
-
sudo apt install ffmpeg # Debian / Ubuntu
|
|
34
|
-
```
|
|
59
|
+
Three cards at the top report video decode (ffmpeg), local transcription, and cloud transcription. Pick one path:
|
|
35
60
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
61
|
+
| Path | Best for | What to do |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| Local (recommended) | Free, offline, no API key | Click "Download local model" (~190 MB), then "Test transcription" |
|
|
64
|
+
| Cloud | You have a key, or the machine is slow | Pick OpenAI / Groq / a custom compatible endpoint, paste the key, save, then test |
|
|
65
|
+
| Skip for now | Videos have subtitles | Use it as is; speech-only videos get no transcript |
|
|
40
66
|
|
|
41
|
-
|
|
67
|
+
Local model steps:
|
|
42
68
|
|
|
43
|
-
|
|
69
|
+
1. Click "Download local model". The progress bar shows bytes received; cancel at any time.
|
|
70
|
+
2. Clicking again after an interruption resumes the download.
|
|
71
|
+
3. When done, the card reads "Ready · whisper.cpp".
|
|
72
|
+
4. Click "Test transcription". "Local engine available" means it works.
|
|
73
|
+
|
|
74
|
+
Cloud key steps:
|
|
75
|
+
|
|
76
|
+
1. Choose a provider under "Cloud transcription key".
|
|
77
|
+
2. Paste the API key and click "Save". After saving, only "Configured" is shown; the key is never echoed back.
|
|
78
|
+
3. Click "Test transcription" to verify the key and network.
|
|
79
|
+
|
|
80
|
+
The default policy is `auto`: use a cloud key when configured, otherwise the local engine. Under "Advanced" you can switch to local only, cloud only, or off.
|
|
81
|
+
|
|
82
|
+
One-click install currently supports Windows x64. On other systems, install whisper.cpp and set `audio.asr.local.binPath` in the config file, or use cloud transcription.
|
|
83
|
+
|
|
84
|
+
## Use it
|
|
85
|
+
|
|
86
|
+
Give the agent a video path and ask:
|
|
44
87
|
|
|
45
88
|
- "What happens in this video?"
|
|
46
|
-
- "What
|
|
47
|
-
- "
|
|
89
|
+
- "What does the text at 12.9 seconds say?"
|
|
90
|
+
- "Take one frame every 5 seconds and describe how it changes."
|
|
91
|
+
- "Transcribe this interview with timestamps."
|
|
92
|
+
|
|
93
|
+
Example output (excerpt):
|
|
94
|
+
|
|
95
|
+
```text
|
|
96
|
+
[Packet #42 | Anchor: #105 | #101(P, 12.1s, Left-Top) → #105(F, 13.4s, Center)]
|
|
97
|
+
Audio @Packet #42: [12.1s-12.9s] "we prepared this for three years" | [13.0s-13.4s] "today we can finally say it"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The text block is structured metadata: each canvas packet reports time, form, anchor, and unit positions; the audio part reports status, source, and per-line timings. The image block is one canvas per packet.
|
|
48
101
|
|
|
49
|
-
|
|
102
|
+
Four ways to look, by question:
|
|
103
|
+
|
|
104
|
+
| Goal | Ask |
|
|
105
|
+
| --- | --- |
|
|
106
|
+
| Overview first | "Look at this video" — streaming sampling; motion as process, settle as detail |
|
|
107
|
+
| One exact moment | "What is written at 12.9s" — deterministic high-resolution frame |
|
|
108
|
+
| Even coverage | "One frame every 5 seconds" — uniform sampling |
|
|
109
|
+
| A region | "Zoom into the bottom right" — crop by area, then look |
|
|
110
|
+
|
|
111
|
+
## Design
|
|
112
|
+
|
|
113
|
+
### Dual-scale streaming perception
|
|
114
|
+
|
|
115
|
+
Video is not sampled at a fixed rate. While the picture moves, low-resolution process units (P) record change; when it settles, high-resolution freeze units (F) keep detail. A single canvas packet carries both process and result, so the model does not need to re-watch a clip to recover one detail.
|
|
116
|
+
|
|
117
|
+
The sampling cadence follows the picture: fast change lowers density to avoid duplicates; slow change waits for a settle before freezing. Long static stretches keep a heartbeat instead of repeating images.
|
|
118
|
+
|
|
119
|
+
### Canvas packing and metering
|
|
120
|
+
|
|
121
|
+
A frame is divided into 42 px superpixel-aligned units. P or F units are taken as needed and packed into one canvas. One call can carry several packets; each packet holds only the units that are new, and older packets collapse into reference hashes instead of resending images. Metering follows the canvas grid (`r × (c + 1) + 2`).
|
|
122
|
+
|
|
123
|
+
### Deterministic inspection
|
|
124
|
+
|
|
125
|
+
Besides streaming, three paths are deterministic: `probe` reads metadata only; `timestamps` returns exact frames in milliseconds; `uniform` samples at a fixed interval; `roi_hint` crops a region. These do not depend on motion detection, so results are reproducible and suited to reading text, numbers, and small objects.
|
|
126
|
+
|
|
127
|
+
### Three sources for speech
|
|
128
|
+
|
|
129
|
+
1. **Subtitles**: a sidecar `.srt` / `.vtt` with the same name first, then embedded soft subtitles.
|
|
130
|
+
2. **Acoustic check**: without subtitles, silence detection and a speech-ratio estimate run first; an all-silent video skips transcription.
|
|
131
|
+
3. **Transcription**: local whisper.cpp, or OpenAI / Groq / a custom compatible endpoint. Segments are mounted on packets by PTS and stitched across block boundaries with a ±300 ms tolerance.
|
|
132
|
+
|
|
133
|
+
The default is "picture first, speech later": when the soft deadline (`graceMs`, 8 s by default) passes, the visual result returns and transcription continues in the background; the next call on the same video hits the disk cache.
|
|
134
|
+
|
|
135
|
+
### Old regions
|
|
136
|
+
|
|
137
|
+
Canvas packets outside the window collapse into references (anchor hash, time, and transcript text) instead of resending images. A timestamp call brings the detail back when needed.
|
|
138
|
+
|
|
139
|
+
## Troubleshooting
|
|
140
|
+
|
|
141
|
+
| Symptom | Read |
|
|
142
|
+
| --- | --- |
|
|
143
|
+
| ffmpeg not found | [ffmpeg](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/排障.md#找不到-ffmpeg) |
|
|
144
|
+
| Speech but no transcript | [No transcript](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/排障.md#有声音但没有台词) |
|
|
145
|
+
| Model download fails or is slow | [Download](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/排障.md#下载失败) |
|
|
146
|
+
| Transcription is slow or times out | [Slow transcription](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/排障.md#转写很慢或超时) |
|
|
147
|
+
| Settings page is read-only | [Read-only config](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/排障.md#设置页只读) |
|
|
148
|
+
|
|
149
|
+
## Docs
|
|
150
|
+
|
|
151
|
+
- [Usage Guide](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/usage-guide.md) (English)
|
|
152
|
+
- [使用指南](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/使用指南.md) (Chinese)
|
|
153
|
+
- [排障](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/排障.md) (Chinese)
|
|
154
|
+
- [开发者指南](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/开发者指南.md) (Chinese): architecture, host contracts, tests, release
|
|
155
|
+
|
|
156
|
+
## Development
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pnpm build
|
|
160
|
+
pnpm test
|
|
161
|
+
pnpm verify:host
|
|
162
|
+
pnpm check:package
|
|
163
|
+
```
|
|
50
164
|
|
|
51
|
-
|
|
165
|
+
The host half provides the `dsh-pf-stream` tool (`probe` / `pf_stream` / `timestamps` / `uniform`), the audio sidecar, the local engine installer, and the settings API. The client half is `client.js`, which registers the config panel and the setup card on the plugin detail page. The only runtime dependency is `pngjs`.
|
|
52
166
|
|
|
53
|
-
|
|
54
|
-
- [Usage Guide](docs/usage-guide.md) (English)
|
|
55
|
-
- [发布规范](docs/发布规范.md) (release process)
|
|
167
|
+
Configuration is written through `ctx.configEditor.edit()`, which keeps fields the user did not touch; keys live in `ctx.credentials`, and the config file only holds a reference.
|
|
56
168
|
|
|
57
169
|
## License
|
|
58
170
|
|
package/README.md
CHANGED
|
@@ -1,58 +1,170 @@
|
|
|
1
1
|
# dsh-pf-stream
|
|
2
2
|
|
|
3
|
-
**中文** | [English](README.en.md)
|
|
3
|
+
**中文** | [English](https://github.com/Weilv-D/dsh-pf-stream/blob/main/README.en.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
让智能体看懂视频:动态抽帧,加上台词。
|
|
6
|
+
|
|
7
|
+
## 能做什么
|
|
8
|
+
|
|
9
|
+
- **看画面**:画面运动时记录过程,停稳时定格细节;指定时间点可以高清复核。
|
|
10
|
+
- **听声音**:有字幕就用字幕;没有字幕时,配置转写引擎后生成台词,并按时间挂到对应画面。
|
|
11
|
+
- **按需配置**:不配置转写也能处理画面;配置后可以处理带音轨的视频。
|
|
6
12
|
|
|
7
13
|
## 安装
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
### 第一步:安装 ffmpeg
|
|
16
|
+
|
|
17
|
+
插件用 ffmpeg 解码视频。先确认它能运行:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
ffmpeg -version
|
|
21
|
+
ffprobe -version
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
两条都要有输出。没有的话:
|
|
10
25
|
|
|
11
|
-
|
|
26
|
+
| 系统 | 安装命令 |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| Windows | `winget install Gyan.FFmpeg` |
|
|
29
|
+
| macOS | `brew install ffmpeg` |
|
|
30
|
+
| Ubuntu / Debian | `sudo apt install ffmpeg` |
|
|
12
31
|
|
|
13
|
-
|
|
32
|
+
装完新开一个终端再验证。不想放进 PATH,可以在插件配置里写 `ffmpegPath` 与 `ffprobePath` 的绝对路径。
|
|
33
|
+
|
|
34
|
+
### 第二步:在 DSH 里安装插件
|
|
35
|
+
|
|
36
|
+
1. 打开 DSH,点左侧栏的「插件」。
|
|
37
|
+
2. 在列表里找「视频理解」(包名 `dsh-pf-stream`)。
|
|
38
|
+
3. 点进详情页,把右上角的开关打开。
|
|
39
|
+
4. 第一次开启后,详情页会出现引导卡片。
|
|
40
|
+
|
|
41
|
+
列表里没有时,用插件页的安装入口从 npm 安装 `dsh-pf-stream`,装完再回到这一步。
|
|
42
|
+
|
|
43
|
+
也可以把安装交给智能体:
|
|
14
44
|
|
|
15
45
|
```text
|
|
16
|
-
安装 DSH 插件 dsh-pf-stream
|
|
17
|
-
1. 用插件管理器从 npm
|
|
18
|
-
2. 检查 ffmpeg 与 ffprobe
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Linux 用 sudo apt install ffmpeg。
|
|
22
|
-
3. 对一个本地视频调用 probe。返回时长与分辨率即成功。
|
|
23
|
-
4. 汇报插件版本、ffmpeg 位置、验证结果。
|
|
46
|
+
安装 DSH 插件 dsh-pf-stream:
|
|
47
|
+
1. 用插件管理器从 npm 安装最新版本,结果为 applied 才算成功;
|
|
48
|
+
2. 检查 ffmpeg 与 ffprobe;缺失时安装(Windows: winget install Gyan.FFmpeg / macOS: brew install ffmpeg / Linux: sudo apt install ffmpeg);
|
|
49
|
+
3. 对一个本地视频调用 probe;返回时长与分辨率即成功;
|
|
50
|
+
4. 汇报插件版本、ffmpeg 位置与检查结果。
|
|
24
51
|
```
|
|
25
52
|
|
|
26
|
-
|
|
53
|
+
## 第一次配置转写
|
|
54
|
+
|
|
55
|
+
转写引擎决定「没有字幕的视频能不能拿到台词」。不配置也能看画面,只是不会生成转写文本。
|
|
27
56
|
|
|
28
|
-
|
|
57
|
+
进入配置页:**左侧栏「插件」→ 点「视频理解」→ 详情页描述下方的面板**。以后要改设置,走同一条路。
|
|
29
58
|
|
|
30
|
-
|
|
31
|
-
winget install Gyan.FFmpeg # Windows
|
|
32
|
-
brew install ffmpeg # macOS
|
|
33
|
-
sudo apt install ffmpeg # Debian / Ubuntu
|
|
34
|
-
```
|
|
59
|
+
面板顶部有三张状态卡:视频解码(ffmpeg)、本地转写、云端转写。按需要选一条路线:
|
|
35
60
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
61
|
+
| 路线 | 适合 | 操作 |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| 本地转写(推荐) | 免费、离线、不填密钥 | 点「下载本地模型」,约 190 MB;下载完点「测试转写」 |
|
|
64
|
+
| 云端转写 | 已有 API Key,或机器性能较弱 | 选 OpenAI / Groq / 自定义兼容端点,填 Key,保存后点「测试转写」 |
|
|
65
|
+
| 暂不配置 | 视频都有字幕 | 直接使用;无字幕的语音视频不会生成转写文本 |
|
|
40
66
|
|
|
41
|
-
|
|
67
|
+
本地模型的下载步骤:
|
|
42
68
|
|
|
43
|
-
|
|
69
|
+
1. 点「下载本地模型」。进度条显示已下载大小,可随时取消。
|
|
70
|
+
2. 下载中断后再次点击会续传,不用从头开始。
|
|
71
|
+
3. 完成后状态卡显示「已就绪 · whisper.cpp」。
|
|
72
|
+
4. 点「测试转写」。返回「本地引擎可用」即配置成功。
|
|
73
|
+
|
|
74
|
+
云端密钥的保存步骤:
|
|
75
|
+
|
|
76
|
+
1. 在「云端转写密钥」里选服务商。
|
|
77
|
+
2. 粘贴 API Key,点「保存」。保存后只显示「已配置」,不再回显密钥。
|
|
78
|
+
3. 点「测试转写」验证密钥与网络。
|
|
79
|
+
|
|
80
|
+
默认策略是 `auto`:云端密钥、端点、模型都齐时用云端(更快,按量计费);否则用本地引擎。面板标题旁会显示当前实际使用的引擎,如「转写可用 · 云端」。可以在「高级」里改成仅本地、仅云端或不转写。
|
|
81
|
+
|
|
82
|
+
一键安装当前支持 Windows x64。其他系统请先安装 whisper.cpp,在配置文件 `audio.asr.local.binPath` 填写可执行文件路径,或改用云端转写。
|
|
83
|
+
|
|
84
|
+
## 开始使用
|
|
85
|
+
|
|
86
|
+
在对话里直接给视频路径并提问:
|
|
44
87
|
|
|
45
88
|
- 「这个视频里发生了什么?」
|
|
46
89
|
- 「第 12.9 秒的文字写的是什么?」
|
|
47
90
|
- 「每 5 秒抽一帧,看画面怎么变化。」
|
|
91
|
+
- 「把这段访谈里说的话按时间整理出来。」
|
|
92
|
+
|
|
93
|
+
返回示例(节选):
|
|
94
|
+
|
|
95
|
+
```text
|
|
96
|
+
[Packet #42 | Anchor: #105 | #101(P, 12.1s, Left-Top) → #105(F, 13.4s, Center)]
|
|
97
|
+
Audio @Packet #42: [12.1s-12.9s] "这件事我们准备了三年" | [13.0s-13.4s] "今天终于可以说了"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
文本块是结构化元数据:每个画布包给出时间、形态、锚点与单元位置;音频部分给出状态、来源与逐句时间。图像块是每个画布包一张画布。
|
|
48
101
|
|
|
49
|
-
|
|
102
|
+
常用问法对应四种取帧方式:
|
|
103
|
+
|
|
104
|
+
| 想要 | 说法 |
|
|
105
|
+
| --- | --- |
|
|
106
|
+
| 先看整体 | 「看看这个视频」——流式采样,运动记过程、停稳给细节 |
|
|
107
|
+
| 只看某一秒 | 「第 12.9 秒写了什么」——定点高清帧 |
|
|
108
|
+
| 均匀看一遍 | 「每 5 秒抽一帧」——等间隔抽帧 |
|
|
109
|
+
| 看局部 | 「放大右下角」——按区域裁剪后再看 |
|
|
110
|
+
|
|
111
|
+
## 特点
|
|
112
|
+
|
|
113
|
+
### 双尺度流式感知
|
|
114
|
+
|
|
115
|
+
视频不再平均抽帧。画面运动时,插件用低分辨率的过程单元(P)记录变化;画面停稳后,用高分辨率的定格单元(F)保留细节。同一个画布包里既有过程也有结果,模型不用为了一个细节反复回看整段视频。
|
|
116
|
+
|
|
117
|
+
采样节奏由画面变化驱动:变化快时降低采样密度、避免重复帧;变化慢时等待停稳再定格。长静止画面用心跳保持时间感,不重复发图。
|
|
118
|
+
|
|
119
|
+
### 画布打包与计费
|
|
120
|
+
|
|
121
|
+
一帧画面被切成 42px 超像素对齐的单元,按需取 P 或 F,再拼成一张画布。一次调用可以带多个画布包;每个包只包含当前新增的单元,历史包以引用哈希折叠,不重复传图。计费按画布网格计算(`r × (c + 1) + 2`)。
|
|
122
|
+
|
|
123
|
+
### 确定性检视
|
|
124
|
+
|
|
125
|
+
流式采样之外,另外三条路径是确定性的:`probe` 只读元数据;`timestamps` 按毫秒取指定帧;`uniform` 按固定间隔取帧;`roi_hint` 裁剪指定区域。这几种不依赖运动检测,结果可复现,适合核对文字、数字与小目标。
|
|
126
|
+
|
|
127
|
+
### 台词的三级来源
|
|
128
|
+
|
|
129
|
+
1. **字幕**:优先用外挂同名 `.srt` / `.vtt`,其次内嵌软字幕。
|
|
130
|
+
2. **声学判断**:没有字幕时先做静音检测与语音占比估计;全程静音的视频直接跳过转写。
|
|
131
|
+
3. **语音转写**:本地 whisper.cpp,或 OpenAI / Groq / 自定义兼容端点。转写结果按 PTS 挂到对应画布包,跨块边界按 ±300ms 缝合。
|
|
132
|
+
|
|
133
|
+
默认「先回画面、后台补台词」:首次调用超过软截止(`graceMs`,默认 8 秒)就先返回视觉结果,转写在后台继续;同一视频再调用时直接命中磁盘缓存。
|
|
134
|
+
|
|
135
|
+
### 长视频的冷区
|
|
136
|
+
|
|
137
|
+
超出窗口的历史画布包会折叠成引用(锚点哈希 + 时间 + 台词文本),不重复传图。需要回看时再按时间点取帧。
|
|
138
|
+
|
|
139
|
+
## 遇到问题
|
|
140
|
+
|
|
141
|
+
| 现象 | 先看这里 |
|
|
142
|
+
| --- | --- |
|
|
143
|
+
| 提示找不到 ffmpeg | [排障:ffmpeg](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/排障.md#找不到-ffmpeg) |
|
|
144
|
+
| 有声音,但没有台词 | [排障:没有台词](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/排障.md#有声音但没有台词) |
|
|
145
|
+
| 下载模型失败或很慢 | [排障:下载失败](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/排障.md#下载失败) |
|
|
146
|
+
| 转写很慢、超时 | [排障:转写慢](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/排障.md#转写很慢或超时) |
|
|
147
|
+
| 设置页显示「只读」 | [排障:配置只读](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/排障.md#设置页只读) |
|
|
50
148
|
|
|
51
149
|
## 文档
|
|
52
150
|
|
|
53
|
-
- [使用指南](docs/使用指南.md)
|
|
54
|
-
- [
|
|
55
|
-
- [
|
|
151
|
+
- [使用指南](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/使用指南.md):用法、参数、返回内容、计费、全部配置项
|
|
152
|
+
- [排障](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/排障.md):按现象查原因
|
|
153
|
+
- [开发者指南](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/开发者指南.md):架构、宿主契约、测试与发布
|
|
154
|
+
- [Usage Guide](https://github.com/Weilv-D/dsh-pf-stream/blob/main/docs/usage-guide.md)(English)
|
|
155
|
+
|
|
156
|
+
## 本地开发
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pnpm build
|
|
160
|
+
pnpm test
|
|
161
|
+
pnpm verify:host
|
|
162
|
+
pnpm check:package
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Host 半提供工具 `dsh-pf-stream`(`probe` / `pf_stream` / `timestamps` / `uniform`)、音频边车、本地引擎安装器与设置接口;Client 半是 `client.js`,在插件详情页注册配置面板与引导卡片。运行时依赖只有 `pngjs`。
|
|
166
|
+
|
|
167
|
+
配置通过 `ctx.configEditor.edit()` 写入,保留用户未触碰的字段;密钥通过 `ctx.credentials` 存取,配置文件只保留引用。
|
|
56
168
|
|
|
57
169
|
## 许可证
|
|
58
170
|
|