@deepwhale-cn/dsh-media-batch 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +98 -2
- package/bin/cli.mjs +1101 -0
- package/cordis.patch.yml +4 -0
- package/lib/index.js +10 -0
- package/lib/watermark_png.py +64 -0
- package/package.json +17 -4
- package/skill/media-batch.md +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 深鲸 DeepWhale
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,99 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @deepwhale-cn/dsh-media-batch
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://dsh-plugin.org/plugins/feely0208/dsh-media-batch)
|
|
4
|
+
|
|
5
|
+
**视频批量处理**:批量压缩、转码、按间隔抽帧、抽音轨、加文字水印、烧录字幕 —— 基于本机 ffmpeg,不上传、不改原片。
|
|
6
|
+
|
|
7
|
+
**关键词**:视频批量压缩 · 视频转码 · 视频抽帧 · 提取音频 · 视频加水印 · 字幕烧录 · ffmpeg 批处理 · media-batch
|
|
8
|
+
|
|
9
|
+
## 不装会怎样
|
|
10
|
+
|
|
11
|
+
一堆录屏、素材、课程视频要压小、要统一成 MP4、要每隔几秒截一张图、要提音频、要打水印或压字幕 ——
|
|
12
|
+
在线工具要上传原片(隐私和体积都不划算),ffmpeg 命令又长又容易记错参数,批量还要自己写循环。
|
|
13
|
+
这个插件把常用动作包成统一命令:**输入只读、输出独立目录、同名自动加序号、结果可 ffprobe 核对**。
|
|
14
|
+
|
|
15
|
+
## 能做什么
|
|
16
|
+
|
|
17
|
+
| 子命令 | 做什么 | 可核对的产物 |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `compress` | H.264 CRF 压缩(可调 `--crf` / `--preset`) | MP4,ffprobe 可读出 h264、分辨率与时长不变 |
|
|
20
|
+
| `transcode` | 换格式(mp4/mov/webm/mkv)、改分辨率、改帧率 | 目标格式文件,ffprobe 编码/分辨率与参数一致 |
|
|
21
|
+
| `frames` | 按固定间隔抽帧为 PNG | `<名称>_frames/` 下编号 PNG,数量 = 时长 ÷ 间隔 |
|
|
22
|
+
| `audio` | 抽音轨为 m4a / mp3 | 纯音频文件,ffprobe 可读出 aac / mp3 |
|
|
23
|
+
| `watermark` | 文字水印(中文可用,五档位置) | 视频,同一时间点画面与源片不同 |
|
|
24
|
+
| `subtitle` | 烧录 `.srt` 字幕(需 ffmpeg 带 libass) | 视频,字幕已压进画面 |
|
|
25
|
+
|
|
26
|
+
- 支持单文件、多文件或单层目录批量;输出默认 `<输入目录>/_输出`,`--out` 可指定。
|
|
27
|
+
- `--json` 给脚本/CI 用;`--probe` 探测本机 ffmpeg 能力;`--demo` 自造 1 秒样例跑完整流程。
|
|
28
|
+
- 文字水印**两条真实路径**:有 `drawtext` 用 drawtext;没有(缺 libfreetype)自动回退为
|
|
29
|
+
「Pillow 渲染透明文字 PNG → ffmpeg overlay 合成」,并在结果里标明 `renderer`。
|
|
30
|
+
|
|
31
|
+
## 不能做什么
|
|
32
|
+
|
|
33
|
+
- ❌ **不下载/不转码受 DRM 保护的流**;不处理损坏文件(会报错并保留原片)。
|
|
34
|
+
- ❌ **不做语音识别**:`subtitle` 只烧录已有 `.srt`,不生成字幕。
|
|
35
|
+
- ❌ **本机 ffmpeg 没编 libass 时不能烧字幕**:会明确报「本机 ffmpeg 无字幕烧录能力」并退出,不假装成功。
|
|
36
|
+
- ❌ **不保证压缩后一定更小**:极短/低码率视频可能变大,结果里会如实给出 `smaller: false`。
|
|
37
|
+
- ❌ 不做多音轨/多字幕流选择(默认取第一路视频 + 可选第一路音频),不做 HDR/杜比处理。
|
|
38
|
+
- ⚠️ 批量只扫**单层目录**;同名输出自动加 `-1`/`-2`,不覆盖。
|
|
39
|
+
- ⚠️ 文字水印的字体来自系统字体;若系统字体被裁剪、且 ffmpeg 无 drawtext,回退路径会明确报缺字体/Pillow。
|
|
40
|
+
|
|
41
|
+
## 安装
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
dsh plugin --profile web add @deepwhale-cn/dsh-media-batch
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
依赖 **ffmpeg / ffprobe**(视频处理全部由它们完成)。缺失时会明确报「缺什么、怎么装」:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
brew install ffmpeg
|
|
51
|
+
dsh-media-batch --probe # 确认 libx264 / aac / drawtext / libass 等能力
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
> 字幕烧录需要 ffmpeg 编译时带 **libass**;本工具会先探测,没有就明确拒绝。
|
|
55
|
+
> 文字水印在缺少 drawtext 时自动回退为 PNG + overlay(额外需要 python3 + Pillow)。
|
|
56
|
+
|
|
57
|
+
## 用法
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# 看效果(自造 1 秒样例,不碰你的文件)
|
|
61
|
+
dsh-media-batch --demo
|
|
62
|
+
|
|
63
|
+
# 压缩整个目录
|
|
64
|
+
dsh-media-batch compress --crf 28 --input videos/
|
|
65
|
+
|
|
66
|
+
# 转码 + 改分辨率
|
|
67
|
+
dsh-media-batch transcode --format mp4 --width 1280 --input a.mov
|
|
68
|
+
|
|
69
|
+
# 每 0.5 秒抽一帧
|
|
70
|
+
dsh-media-batch frames --every 0.5 --input clip.mp4
|
|
71
|
+
|
|
72
|
+
# 抽音轨
|
|
73
|
+
dsh-media-batch audio mp3 --input clip.mp4
|
|
74
|
+
|
|
75
|
+
# 文字水印
|
|
76
|
+
dsh-media-batch watermark --text "内部资料" --position br --input clip.mp4
|
|
77
|
+
|
|
78
|
+
# 烧字幕(本机无 libass 会明确报错)
|
|
79
|
+
dsh-media-batch subtitle --subtitle a.srt --input clip.mp4
|
|
80
|
+
|
|
81
|
+
# 给程序:JSON 输出
|
|
82
|
+
dsh-media-batch compress --input videos/ --json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
退出码:`0` 成功 / `2` 参数或输入错误 / `3` 依赖或能力缺失 / `4` 执行失败。
|
|
86
|
+
|
|
87
|
+
## 自测
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
bash tests/run.sh
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
测试会自己用 `ffmpeg lavfi` 造 1 秒样例(含音轨/无音轨各一),逐项核对压缩后体积、编码器、
|
|
94
|
+
转码分辨率、抽帧数量、抽音轨可被 ffprobe 读出、水印画面与源片不同,并按本机能力走
|
|
95
|
+
字幕烧录/明确拒绝两条分支;同时验证「输入哈希不变」「不存在文件必须非 0」等反例。
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT © 温州深鲸智能科技有限公司
|