⏳ This skill is pending AI review.

Scores will appear once the review pipeline completes.

v1.0.0

video-scrub

eternityspring@eternityspring⭐ 1.2k stars· last commit 6d ago· 0 open issues

|

Choose how to use this skill

You do not need every option. Choose the path your AI client supports. The stable page stays the same; versioned files are immutable.

1. Native installer

This listing has no registered native installer command. Use the complete package or source fallback below, depending on what your client supports.

Do not guess an installer command or replace an existing version without reviewing the diff.

2. Complete package recommended

Download the ZIP when available. It includes SKILL.md plus the references, security notes and version metadata.

No complete ProSkills package is published for this listing yet.

3. Prompt-only

Copy the prompt above when the agent can read the stable page or when you want to adopt the workflow without installing a skill.

Need only the instruction file?

Download SKILL.md only if your client requires a single file. The complete ZIP is safer for a full installation because it preserves the references and release context.

No path installs or executes anything by itself. Your agent still needs access to the project files. Before updating, compare the installed version and review the diff.

—/10

// RATINGS

⭐GitHub Stars
⭐⭐⭐⭐⭐ 1.2k on GitHubGitHub ↗

Very popular

🟢ProSkills Score
—
📍

Not yet listed on ClawHub or SkillsMP

// README

中文 English

video-scrub

把一条视频重建成干净文件:画面和声音带过去,源片的元数据一个字节都不带。

GPS、设备型号、账号 ID、创建时间、章节、GoPro 的遥测轨——全部留在原地。

白名单,不是黑名单

清元数据有两种思路,差别是死活:

怎么做问题
黑名单列出要删的字段逐个删(exiftool 那种)删不完你不知道的东西
白名单不说删什么,只说带什么过去:画面一条流、声音一条流,别的一律不要——

走白名单,源片的元数据没有任何通道能进来。它不是「被删掉了」,是从来没被搬运。 隐私保证来自结构,不来自枚举。

难的不是 tag,是看不见的那几层

-map_metadata -1 之后 ffprobe 一片安静。但文件里还躺着三处身份串:

藏在哪内容ffprobe 看得见
H.264 的 SEIx264 - core 165 ... cabac=1 ref=3 ... crf=23.0✗
AAC 码流的 DSELavc62.28.102✗
avc1 的 compressornameLavc libx264✗

加上容器 tag 和 handler_name,一共五个藏身处,少堵一个都不算干净。 每一处的堵法、以及几个「看着该管用其实没用」的坑(-flags:v +bitexact 和 -x264-params info=0 都拦不住 SEI),全部记在 references/residue-map.md。

还有一类不在这五处、但同样要命的:GoPro 和 DJI 的 GPS 不在任何 tag 里, 在一条独立的 gpmd 定时元数据轨上。清 tag 清不掉,只有「只挑视频和音频两条流」挡得住。

默认不损画质

node scripts/video-scrub.mjs run <video> -o out.mp4
模式画面音频速度
copy(默认)逐字节照搬重编53 秒的片子 1.3 秒
encode重编码重编慢得多

画面在 copy 模式下真的一个比特都没动——抽出前后的 H.264 码流 cmp 过, 除了被摘掉的 SEI 之外逐字节一致。

音频两种模式都重编:AAC 的版本号写在 DSE 里,那是码流内部,-c:a copy 抹不掉它。

关于水印:encode 比 copy 多杀的是码流域水印和脆弱隐写,实际素材里少见。 真正要命的鲁棒像素水印(SynthID、影视取证水印)设计目标就是扛住重编码, 两种模式都杀不掉。选模式按画质和速度选,别指望重编码能洗掉水印。

验收不靠声称

前面全是「我调了正确的参数」,属于声称。验收这一步是「我扫了,真没了」,属于证明。

把源片所有元数据字符串抓出来当针——tag 的键和值、handler 名、章节标题—— 在输出文件里做字节级扫描,扎到一根就红。

demo2.mp4 → clean.mp4 copy / obs
扫了 14 根针

  ✓ 字节级残留      ✓ 流构成
  ✓ tag 层残留      ✓ 章节
  ✓ 位置信息        ✓ 码流身份串
  ✓ 设备与软件标识   ✓ profile 相符
  ✓ 源片时间戳      ✓ 时长
  – 旋转矩阵        ✓ 可解码

✅ 12 道门全过——源片的元数据一个字节都没剩下

仓库里有一份真跑出来的对账:demo-scrub/——包含一个 最值得看的反例,教科书做法跑完 ffprobe 一片干净,码流身份串那道门照样红。

针的挑选有两条讲究:≥5 字节(更短的会在压缩数据里撞出假阳性), 通用串不当针(VideoHandler 满世界都是;Lavf58.45.100 钉死一个版本,是指纹)。

四个 profile

擦白之后往回写的那一层。--profile <名> 切换:

profile写什么
obs(默认)OBS Studio 的长相。OBS 本来就是 ffmpeg 封装的,这档不是伪造
quicktimemacOS QuickTime 录屏:Core Media Video / Core Media Audio
screencaptureScreenCaptureKit 录屏
bare什么都不写。隐私强度最高——不留任何可被证伪的声明

profile 只碰三样东西:封装工具的痕迹、handler 名、创建时间。 不写设备型号、不写 GPS、不写作者和账号。 详见 references/profiles.md。

命令

inspect <video>                    # 先看源片带了什么,含码流里那几处看不见的
scrub   <video> -o out.mp4         # 清
verify  <源> <输出>                 # 扫残留,出 12 道门的清单
run     <video> -o out.mp4         # scrub + verify 一条龙,日常用这个

常用参数:

--mode encode                  # 完整重编码
--profile bare                 # 什么都不写
--crf 18                       # 只在 encode 模式有意义
--date 2026-01-01T00:00:00Z    # 指定创建时间
--json                         # inspect / verify 出 JSON

HDR 与内嵌字幕:SEI 这刀什么时候不许动

ffmpeg 只给得起 NAL 级的粒度,remove_types=6 是全部 SEI 一起删。 而 SEI 里除了 x264 那串垃圾,还住着 HDR 静态元数据(删了会掉色)和 CEA-608/708 内嵌字幕(删了字幕没了)。

所以策略是有条件动刀:只在真查到身份串时才删,HDR 源片一律不动(会明说没动,以及为什么)。

边界(不做的事)

不去除水印、不改画面内容(不裁剪不缩放不旋转)、不伪造设备型号和 GPS、 不做批量目录扫描、不处理 mp4/mov 之外的容器。

依赖与自测

只要 node >= 18 和 ffmpeg / ffprobe。零 npm 依赖、零 API key。

node scripts/selftest.mjs

117 项断言,不碰 ffmpeg、不碰真文件。12 道门每道都有击穿用例——证明它真的会拦。

// HOW IT'S BUILT

// FILES

7 files shipped with this skill. Inline text is the catalog copy. The upstream link is the source repository.

  • skills/video-scrub/SKILL.md9.1 KB58e59cc5756fupstream ↗
    ---
    name: video-scrub
    version: 1.0.0
    description: |
      把一条视频重建成「只有画面和声音」的干净文件——**源片的元数据一概不搬**:
      GPS、设备型号、账号 ID、创建时间、章节、GoPro 的遥测轨,全部留在原地。
      走的是白名单而不是黑名单:不列要删什么,只说带什么过去(画面一条流、声音一条流),
      隐私保证来自结构,不来自枚举。
      难点不在容器 tag,在**看不见的那几层**:x264 把完整编码参数写成 SEI 塞在码流里、
      AAC 把版本号写进 DSE、avc1 的 compressorname 里还有一份——`ffprobe` 一个都看不见。
      五个藏身处逐一堵死,每一处都有实测。
      默认 `--mode copy`:**画面逐字节照搬**(cmp 验证过),只重编音频,53 秒的片子 1.3 秒跑完;
      `--mode encode` 完整重编码,多杀掉码流域的东西。
      验收不靠声称:把源片所有元数据字符串当「针」,在输出文件里做**字节级扫描**,
      扎到一根就红。12 道门全部由脚本确定性检查。
      零依赖、零 API key,只要 node 和 ffmpeg。
      Use when asked to 清元数据、去元数据、抹掉视频信息、视频隐私、去水印信息、
      strip video metadata、remove exif from video、scrub video。
    allowed-tools:
      - Read
      - Write
      - Edit
      - Bash
      - Glob
    triggers:
      - video-scrub
      - 清元数据
      - 去元数据
      - 元数据
      - 视频隐私
      - 抹掉信息
      - strip metadata
      - scrub video
    metadata:
      license: Apache-2.0
      requires:
        bins:
          - node      # >= 18,只用标准库,无 npm 依赖
          - ffmpeg    # 重封装/重编码、码流过滤
          - ffprobe   # 探测 tag、流、章节、side data
      runtimes:
        - claude-code
        - codex
    ---
    
    ## video-scrub
    
    把一条视频重建成干净文件:**画面和声音带过去,元数据一个字节都不带。**
    
    `{baseDir}` = 本文件所在目录。脚本 `{baseDir}/scripts/video-scrub.mjs`,零依赖,`node` 直接跑。
    
    ### 原理:白名单,不是黑名单
    
    清元数据有两种思路,差别是死活:
    
    | | 怎么做 | 问题 |
    | --- | --- | --- |
    | 黑名单 | 列出要删的字段逐个删(exiftool 那种) | **删不完你不知道的东西**——厂商私有的 udta、GoPro 的遥测轨、码流里的 SEI,漏一个就漏了 |
    | **白名单** | 不说删什么,只说**带什么过去**:画面一条流、声音一条流,别的一律不要 | —— |
    
    走白名单,源片的元数据**没有任何通道**能进来。它不是「被删掉了」,是从来没被搬运。
    
    但 ffmpeg 默认会背叛这个结构两次,必须摁住:
    
    1. **它默认把源片的容器 tag 搬到输出** → `-map_metadata -1`
    2. **它默认自动挑流**,会把 GoPro 的 `gpmd` 遥测轨一起带走 → `-map 0:v:0 -map 0:a:0?`
    
    第 2 条是 GoPro / DJI 这类源片的唯一防线:**它们的 GPS 不在 tag 里,在一条独立的定时元数据轨上。**
    清 tag 清不掉,只有「只挑两条流」挡得住。
    
    ### 真正的难点:看不见的那几层
    
    摁住上面两条,tag 层就干净了,`ffprobe` 一片安静。**但文件里还躺着三处身份串**:
    
    | 藏在哪 | 内容 | ffprobe 看得见 |
    | --- | --- | --- |
    | H.264 的 **SEI** | x264 完整参数串 `cabac=1 ref=3 … crf=23.0` | ✗ |
    | AAC 码流的 **DSE** | `Lavc62.28.102` | ✗ |
    | avc1 的 **compressorname** | `Lavc libx264` | ✗ |
    
    五个藏身处和各自的堵法见 `{baseDir}/references/residue-map.md`——**每一条都有实测记录,
    包括几个「看着该管用其实没用」的坑**(`-flags:v +bitexact` 和 `-x264-params info=0` 都拦不住 SEI)。
    
    ### 两种模式
    
    | 模式 | 画面 | 音频 | 速度 | 多杀掉什么 |
    | --- | --- | --- | --- | --- |
    | **`copy`**(默认) | **逐字节照搬** | 重编 | 53 秒的片子 1.3 秒 | —— |
    | `encode` | 重编码 | 重编 | 慢得多 | 码流域水印、脆弱隐写 |
    
    音频**两种模式都重编**——AAC 的版本号写在 DSE 里,那是码流内部,`-c:a copy` 抹不掉它。
    重编一遍很便宜,换来音轨干净。画面则在 copy 模式下**真的一个比特都没动**(`cmp` 验证过,
    除了被摘掉的 SEI)。
    
    **关于水印**:`encode` 比 `copy` 多杀的是码流域水印和脆弱隐写,这两类在实际素材里少见。
    真正要命的**鲁棒像素水印**(SynthID、影视取证水印)设计目标就是扛住重编码,**两种模式都杀不掉**。
    所以选模式按画质和速度选,别指望重编码能洗掉水印。
    
    ### 四个 profile
    
    擦白之后往回写的那一层:
    
    | profile | 写什么 |
    | --- | --- |
    | **`obs`**(默认) | OBS Studio 的长相。OBS 本来就是用 ffmpeg 封装的,所以这档不是伪造,是保持同类工具的正常外观 |
    | `quicktime` | macOS QuickTime 录屏:`Core Media Video` / `Core Media Audio` |
    | `screencapture` | ScreenCaptureKit 录屏 |
    | `bare` | 什么都不写。**隐私强度最高**——不留任何可被证伪的声明 |
    
    有一件事做不到,写在这里省得再试:容器的 `encoder` 字段由 muxer 自己占着,
    `-metadata encoder=Lavf60.16.100` **盖不过去**,置空也清不掉(实测)。只有
    `-fflags +bitexact` 能让它整个消失。所以 `obs` 档不伪造版本号,它就让 ffmpeg 写自己的真版本号。
    
    ---
    
    ### Step 0 — 先看源片带了什么
    
    ```bash
    node {baseDir}/scripts/video-scrub.mjs inspect <video>
    ```
    
    一屏列全:容器 tag、每条流的 tag 与 side data、章节,**以及码流里那几处 `ffprobe` 看不见的身份串**。
    末尾会告诉你验收时要拿几根针去扫,以及 SEI 这刀动不动。
    
    **先看这一屏再动手。** 尤其注意两件事:
    
    - 有没有 `data` / `timecode` 流——有就说明源片可能带遥测轨(GoPro、DJI)
    - 是不是 **HDR**——是的话 SEI 一律不删(下面说为什么)
    
    ### Step 1 — 清
    
    ```bash
    node {baseDir}/scripts/video-scrub.mjs scrub <video> -o out.mp4
    ```
    
    默认 `--mode copy --profile obs`。常用参数:
    
    ```bash
    --mode encode          # 完整重编码
    --profile bare         # 什么都不写,隐私强度最高
    --crf 18               # 只在 encode 模式有意义
    --date 2026-01-01T00:00:00Z   # 指定创建时间,不给就用当前时间
    ```
    
    ### Step 2 — 验收 ⛔ 不能跳
    
    ```bash
    node {baseDir}/scripts/video-scrub.mjs verify <源> <输出>
    ```
    
    或者一条龙(**日常就用这个**):
    
    ```bash
    node {baseDir}/scripts/video-scrub.mjs run <video> -o out.mp4
    ```
    
    验收的核心是一句话:**前面全是「我调了正确的参数」,属于声称;这一步是「我扫了,真没了」,属于证明。**
    
    做法是把源片所有元数据字符串抓出来当「针」——tag 的键和值、handler 名、章节标题——
    在输出文件里做**字节级扫描**,扎到一根就红。
    
    两条实现上的讲究:
    
    - **针要 ≥5 字节**。更短的串会在压缩数据里随机撞出假阳性,跳过的针会在提示里列出来。
    - **通用串不当针**。`VideoHandler` 满世界都是,信息量为零;`Lavf58.45.100` 钉死了一个版本,
      是指纹。分界线是「能不能把范围缩小到某个人、某台设备、某次导出」。
    
    ### 12 道门
    
    | 门 | 拦什么 |
    | --- | --- |
    | 字节级残留 | 源片的元数据串扎中了输出 |
    | tag 层残留 | 输出的 tag 值来自源片 |
    | 位置信息 | 任何 GPS / location 字段 |
    | 设备与软件标识 | make / model / software / artist / comment 之类 |
    | 源片时间戳 | 输出的 creation_time 等于源片的 |
    | 旋转矩阵 | encode 模式下旋转没烘进画面(copy 模式跳过——删了画面就是歪的) |
    | 流构成 | 混进了 data / timecode / 附件流 |
    | 章节 | 章节跟过来了 |
    | 码流身份串 | SEI / DSE / compressorname 里还有编码器名字 |
    | profile 相符 | 剩下的 tag 和声明的 profile 对不上 |
    | 时长 | 输出被偷偷截断 |
    | 可解码 | 产出了打不开的坏文件 |
    
    ### HDR 与内嵌字幕:SEI 这刀什么时候不许动
    
    ffmpeg 只给得起 **NAL 级**的粒度——`filter_units` 按 NAL 类型删,
    `h264_metadata` 也没有「只删某个 SEI payload」的选项。所以 `remove_types=6` 是
    **全部 SEI 一起删**。而 SEI 里除了 x264 那串垃圾,还住着:
    
    - **HDR 静态元数据**(mastering display / content light level)——删了会掉色,tone mapping 崩
    - **CEA-608/708 内嵌字幕**——删了字幕没了
    
    所以脚本的策略是:**只在真查到身份串时才动刀,HDR 源片一律不动**(会明说没动,
    以及为什么)。这个判断由 `seiPlan()` 做,不需要你操心,但你该知道它在那儿。
    
    ### 边界(不做的事)
    
    不去除水印(鲁棒像素水印重编码也杀不掉,别指望)、不改画面内容(不裁剪不缩放不旋转)、
    不伪造设备型号和 GPS(profile 只写工具类信息,不编造拍摄设备和位置)、
    不做批量目录扫描(一次一条片子)、不处理非 mp4/mov 之外的容器。
    
    ### 自测
    
    ```bash
    node {baseDir}/scripts/selftest.mjs
    ```
    
    117 项断言,不碰 ffmpeg、不碰真文件。**12 道门每道都有击穿用例**——证明它真的会拦。
    改完脚本先跑这个。
    
  • skills/video-scrub/README.md5.9 KB5ce37d139003upstream ↗
    [![中文](https://img.shields.io/badge/%E4%B8%AD%E6%96%87-a02128?style=for-the-badge)](README.md)
    [![English](https://img.shields.io/badge/English-ece9e7?style=for-the-badge&labelColor=ece9e7&color=8a8785)](README.en.md)
    
    # video-scrub
    
    把一条视频重建成干净文件:**画面和声音带过去,源片的元数据一个字节都不带。**
    
    GPS、设备型号、账号 ID、创建时间、章节、GoPro 的遥测轨——全部留在原地。
    
    ## 白名单,不是黑名单
    
    清元数据有两种思路,差别是死活:
    
    | | 怎么做 | 问题 |
    | --- | --- | --- |
    | 黑名单 | 列出要删的字段逐个删(exiftool 那种) | **删不完你不知道的东西** |
    | **白名单** | 不说删什么,只说**带什么过去**:画面一条流、声音一条流,别的一律不要 | —— |
    
    走白名单,源片的元数据**没有任何通道**能进来。它不是「被删掉了」,是从来没被搬运。
    隐私保证来自结构,不来自枚举。
    
    ## 难的不是 tag,是看不见的那几层
    
    `-map_metadata -1` 之后 `ffprobe` 一片安静。**但文件里还躺着三处身份串:**
    
    | 藏在哪 | 内容 | ffprobe 看得见 |
    | --- | --- | --- |
    | H.264 的 **SEI** | `x264 - core 165 ... cabac=1 ref=3 ... crf=23.0` | ✗ |
    | AAC 码流的 **DSE** | `Lavc62.28.102` | ✗ |
    | avc1 的 **compressorname** | `Lavc libx264` | ✗ |
    
    加上容器 tag 和 handler_name,一共**五个藏身处**,少堵一个都不算干净。
    每一处的堵法、以及几个「看着该管用其实没用」的坑(`-flags:v +bitexact` 和
    `-x264-params info=0` 都拦不住 SEI),全部记在 [`references/residue-map.md`](references/residue-map.md)。
    
    还有一类不在这五处、但同样要命的:**GoPro 和 DJI 的 GPS 不在任何 tag 里**,
    在一条独立的 `gpmd` 定时元数据轨上。清 tag 清不掉,只有「只挑视频和音频两条流」挡得住。
    
    ## 默认不损画质
    
    ```bash
    node scripts/video-scrub.mjs run <video> -o out.mp4
    ```
    
    | 模式 | 画面 | 音频 | 速度 |
    | --- | --- | --- | --- |
    | **`copy`**(默认) | **逐字节照搬** | 重编 | 53 秒的片子 **1.3 秒** |
    | `encode` | 重编码 | 重编 | 慢得多 |
    
    画面在 copy 模式下真的一个比特都没动——抽出前后的 H.264 码流 `cmp` 过,
    除了被摘掉的 SEI 之外逐字节一致。
    
    音频**两种模式都重编**:AAC 的版本号写在 DSE 里,那是码流内部,`-c:a copy` 抹不掉它。
    
    **关于水印**:`encode` 比 `copy` 多杀的是码流域水印和脆弱隐写,实际素材里少见。
    真正要命的**鲁棒像素水印**(SynthID、影视取证水印)设计目标就是扛住重编码,
    **两种模式都杀不掉**。选模式按画质和速度选,别指望重编码能洗掉水印。
    
    ## 验收不靠声称
    
    前面全是「我调了正确的参数」,属于声称。验收这一步是「我扫了,真没了」,属于证明。
    
    把源片所有元数据字符串抓出来当**针**——tag 的键和值、handler 名、章节标题——
    在输出文件里做**字节级扫描**,扎到一根就红。
    
    ```
    demo2.mp4 → clean.mp4 copy / obs
    扫了 14 根针
    
      ✓ 字节级残留      ✓ 流构成
      ✓ tag 层残留      ✓ 章节
      ✓ 位置信息        ✓ 码流身份串
      ✓ 设备与软件标识   ✓ profile 相符
      ✓ 源片时间戳      ✓ 时长
      – 旋转矩阵        ✓ 可解码
    
    ✅ 12 道门全过——源片的元数据一个字节都没剩下
    ```
    
    仓库里有一份**真跑出来的对账**:[`demo-scrub/`](../../demo-scrub/)——包含一个
    最值得看的反例,教科书做法跑完 `ffprobe` 一片干净,码流身份串那道门照样红。
    
    针的挑选有两条讲究:**≥5 字节**(更短的会在压缩数据里撞出假阳性),
    **通用串不当针**(`VideoHandler` 满世界都是;`Lavf58.45.100` 钉死一个版本,是指纹)。
    
    ## 四个 profile
    
    擦白之后往回写的那一层。`--profile <名>` 切换:
    
    | profile | 写什么 |
    | --- | --- |
    | **`obs`**(默认) | OBS Studio 的长相。OBS 本来就是 ffmpeg 封装的,这档不是伪造 |
    | `quicktime` | macOS QuickTime 录屏:`Core Media Video` / `Core Media Audio` |
    | `screencapture` | ScreenCaptureKit 录屏 |
    | `bare` | 什么都不写。**隐私强度最高**——不留任何可被证伪的声明 |
    
    profile 只碰三样东西:封装工具的痕迹、handler 名、创建时间。
    **不写设备型号、不写 GPS、不写作者和账号。** 详见 [`references/profiles.md`](references/profiles.md)。
    
    ## 命令
    
    ```bash
    inspect <video>                    # 先看源片带了什么,含码流里那几处看不见的
    scrub   <video> -o out.mp4         # 清
    verify  <源> <输出>                 # 扫残留,出 12 道门的清单
    run     <video> -o out.mp4         # scrub + verify 一条龙,日常用这个
    ```
    
    常用参数:
    
    ```bash
    --mode encode                  # 完整重编码
    --profile bare                 # 什么都不写
    --crf 18                       # 只在 encode 模式有意义
    --date 2026-01-01T00:00:00Z    # 指定创建时间
    --json                         # inspect / verify 出 JSON
    ```
    
    ## HDR 与内嵌字幕:SEI 这刀什么时候不许动
    
    ffmpeg 只给得起 NAL 级的粒度,`remove_types=6` 是**全部 SEI 一起删**。
    而 SEI 里除了 x264 那串垃圾,还住着 **HDR 静态元数据**(删了会掉色)和
    **CEA-608/708 内嵌字幕**(删了字幕没了)。
    
    所以策略是有条件动刀:**只在真查到身份串时才删,HDR 源片一律不动**(会明说没动,以及为什么)。
    
    ## 边界(不做的事)
    
    不去除水印、不改画面内容(不裁剪不缩放不旋转)、不伪造设备型号和 GPS、
    不做批量目录扫描、不处理 mp4/mov 之外的容器。
    
    ## 依赖与自测
    
    只要 `node` >= 18 和 `ffmpeg` / `ffprobe`。零 npm 依赖、零 API key。
    
    ```bash
    node scripts/selftest.mjs
    ```
    
    117 项断言,不碰 ffmpeg、不碰真文件。**12 道门每道都有击穿用例**——证明它真的会拦。
    
  • skills/video-scrub/scripts/selftest.mjs17 KB3c86570f99adupstream ↗
    #!/usr/bin/env node
    // video-scrub 自测:不碰 ffmpeg、不碰真文件、不花时间。
    // 12 道门每一道都有**击穿用例**——证明它真的会拦,不是摆设。
    
    import {
      MODES, PROFILES, DEFAULT_PARAMS, STRUCTURAL_TAGS, GENERIC_STRINGS,
      TOOL_MARKS, LOCATION_KEYS, DEVICE_KEYS,
      isIdentifying, isHdr, needlesOf, seiPlan, scrubArgs, verify,
    } from './video-scrub.mjs';
    
    let passed = 0;
    const failures = [];
    
    function ok(cond, label) {
      if (cond) passed += 1;
      else failures.push(label);
    }
    const eq = (got, want, label) =>
      ok(Object.is(got, want), `${label}(得到 ${JSON.stringify(got)},应为 ${JSON.stringify(want)})`);
    
    /* ------------------------------------------------------------------ */
    /* 夹具                                                                */
    /* ------------------------------------------------------------------ */
    
    /** 一份「已经清干净」的探测结果——所有门都该绿。改一处就该红一道。 */
    const cleanOut = () => ({
      file: 'out.mp4',
      durationSeconds: 53.37,
      sizeBytes: 12_400_000,
      formatTags: {
        major_brand: 'isom', minor_version: '512',
        compatible_brands: 'isomiso2avc1mp41',
        encoder: 'Lavf62.12.102',
        creation_time: '2026-09-21T10:00:00.000000Z',
      },
      chapters: [],
      streams: [
        { index: 0, type: 'video', codec: 'h264', tags: { language: 'und', handler_name: 'VideoHandler' }, sideData: [] },
        { index: 1, type: 'audio', codec: 'aac', tags: { language: 'und', handler_name: 'SoundHandler' }, sideData: [] },
      ],
      hasAudio: true,
      video: { width: 1312, height: 736, pixFmt: 'yuv420p', colorSpace: null, colorTransfer: null, colorPrimaries: null },
    });
    
    /** 一份脏源片:GPS、邮箱、抖音 ID、设备名、章节、一条 data 轨。 */
    const dirtySrc = () => ({
      file: 'src.mp4',
      durationSeconds: 53.37,
      sizeBytes: 12_000_000,
      formatTags: {
        major_brand: 'isom', minor_version: '512',
        compatible_brands: 'isomiso2avc1mp41',
        creation_time: '2025-03-14T08:22:11.000000Z',
        artist: '[email protected]',
        album: 'iPhone 15 Pro',
        comment: 'vid:v1e00fgi0000da64usvog65t9bk1rqgg',
        location: '+31.2304+121.4737/',
        encoder: 'Lavf58.45.100',
      },
      chapters: [{ tags: { title: '在家拍的第一段' } }],
      streams: [
        { index: 0, type: 'video', codec: 'h264', tags: { language: 'und', handler_name: 'VideoHandler' }, sideData: [] },
        { index: 1, type: 'audio', codec: 'aac', tags: { language: 'und', handler_name: 'SoundHandler' }, sideData: [] },
        { index: 2, type: 'data', codec: 'bin_data', tags: { handler_name: 'SubtitleHandler' }, sideData: [] },
      ],
      hasAudio: true,
      video: { width: 1312, height: 736, pixFmt: 'yuv420p', colorSpace: null, colorTransfer: null, colorPrimaries: null },
    });
    
    const run = (over = {}) => verify({
      src: dirtySrc(), out: cleanOut(), residue: [], toolMarks: [],
      profile: 'obs', mode: 'copy', params: DEFAULT_PARAMS, ...over,
    });
    const gateOf = (v, id) => v.gates.find((g) => g.id === id);
    const fails = (over, id, label) => {
      const g = gateOf(run(over), id);
      ok(g && !g.ok && !g.skipped, `${label} —— ${id} 门应该拦下`);
    };
    const holds = (over, id, label) => {
      const g = gateOf(run(over), id);
      ok(g && g.ok, `${label} —— ${id} 门不该拦(${g?.issues?.join(';')})`);
    };
    
    /* ------------------------------------------------------------------ */
    /* 基线:干净的输出必须全绿                                             */
    /* ------------------------------------------------------------------ */
    {
      const v = run();
      ok(v.ok, `基线该全绿,红的是:${v.failed.map((g) => g.id).join('、')}`);
      eq(v.gates.length, 12, '一共 12 道门');
      eq(v.gates.filter((g) => g.skipped).length, 1, 'copy 模式下旋转矩阵那道跳过');
    }
    
    /* ------------------------------------------------------------------ */
    /* 12 道门的击穿用例                                                    */
    /* ------------------------------------------------------------------ */
    
    /* 1. 字节级残留 */
    fails({ residue: [{ needle: '[email protected]', count: 1, offset: 12031634 }] },
      'residue', '源片的邮箱出现在输出字节里');
    fails({ residue: [{ needle: 'vid:v1e00fgi0000da64usvog65t9bk1rqgg', count: 1, offset: 999 }] },
      'residue', '抖音 ID 出现在输出字节里');
    
    /* 豁免:obs 档自己写回去的 encoder 不算残留 */
    {
      const v = run({ residue: [{ needle: 'Lavf62.12.102', count: 1, offset: 43011 }] });
      ok(gateOf(v, 'residue').ok, 'obs 档自己写的 Lavf 版本号该豁免,不算残留');
      ok(v.hints.some((h) => h.includes('豁免')), '豁免了要在提示里说清楚');
    }
    /* 但豁免不能开口子:版本号对不上 profile 就不豁免 */
    {
      const out = cleanOut();
      out.formatTags.encoder = 'Lavf62.12.102';
      const v = verify({
        src: dirtySrc(), out, profile: 'obs', mode: 'copy',
        residue: [{ needle: 'Lavf58.45.100', count: 1, offset: 1 }], toolMarks: [],
      });
      ok(!gateOf(v, 'residue').ok, '源片的旧 Lavf 版本号漏过来了,不该被豁免');
    }
    
    /* 2. tag 层残留 */
    {
      const out = cleanOut();
      out.formatTags.artist = '[email protected]';
      fails({ out }, 'tags', '源片的 artist 值原样出现在输出 tag 里');
    }
    /* 通用串不算残留:obs 档写回 VideoHandler 天经地义 */
    holds({}, 'tags', 'VideoHandler 是通用串,源片有输出也有,不该算残留');
    
    /* 3. 位置 */
    {
      const out = cleanOut();
      out.formatTags.location = '+31.2304+121.4737/';
      fails({ out }, 'gps', '输出还留着 location');
    }
    {
      const out = cleanOut();
      out.streams[0].tags['com.apple.quicktime.location.ISO6709'] = '+31.2+121.4/';
      fails({ out }, 'gps', '输出的流上还挂着苹果的位置字段');
    }
    
    /* 4. 设备与软件 */
    {
      const out = cleanOut();
      out.formatTags.album = 'iPhone 15 Pro';
      fails({ out }, 'device', '输出还留着设备名');
    }
    {
      const out = cleanOut();
      out.formatTags.comment = 'vid:v1e00fgi0000da64usvog65t9bk1rqgg';
      fails({ out }, 'device', '输出还留着 comment 里的账号 ID');
    }
    /* profile 明说要写的不算违规 */
    holds({}, 'device', 'obs 档的 encoder 和 creation_time 是自己写的,不算设备标识');
    
    /* 5. 源片时间戳 */
    {
      const out = cleanOut();
      out.formatTags.creation_time = '2025-03-14T08:22:11.000000Z';
      fails({ out }, 'creation', '输出的 creation_time 和源片一模一样');
    }
    {
      const out = cleanOut();
      delete out.formatTags.creation_time;
      out.streams[0].tags.creation_time = '2025-03-14T08:22:11.000000Z';
      fails({ out }, 'creation', '时间戳躲到流级去了,一样要拦');
    }
    
    /* 6. 旋转矩阵 */
    {
      const out = cleanOut();
      out.streams[0].sideData = [{ side_data_type: 'Display Matrix' }];
      fails({ out, mode: 'encode' }, 'rotation', 'encode 模式下旋转该烘进画面,不该留矩阵');
      const g = gateOf(run({ out, mode: 'copy' }), 'rotation');
      ok(g.skipped, 'copy 模式下这道门跳过——删了矩阵画面就是歪的');
    }
    
    /* 7. 流构成 */
    {
      const out = cleanOut();
      out.streams.push({ index: 2, type: 'data', codec: 'bin_data', tags: {}, sideData: [] });
      fails({ out }, 'streams', 'GoPro 的 gpmd 遥测轨跟过来了');
    }
    {
      const out = cleanOut();
      out.streams = out.streams.filter((s) => s.type !== 'video');
      fails({ out }, 'streams', '一条视频流都没有');
    }
    {
      const out = cleanOut();
      out.streams.push({ index: 2, type: 'audio', codec: 'aac', tags: {}, sideData: [] });
      fails({ out }, 'streams', '音频流多于一条');
    }
    
    /* 8. 章节 */
    {
      const out = cleanOut();
      out.chapters = [{ tags: { title: '在家拍的第一段' } }];
      fails({ out }, 'chapters', '章节跟过来了');
    }
    
    /* 9. 码流身份串 */
    fails({ toolMarks: [{ mark: 'x264 - core', count: 4, offset: 73 }] },
      'bitstream', 'x264 的 SEI 参数串还在码流里');
    fails({ toolMarks: [{ mark: 'Lavc', count: 8, offset: 146686 }] },
      'bitstream', 'AAC 的 DSE 里还有 Lavc 版本号');
    /* obs 档留着的那一处 Lavf 不算 */
    holds({ toolMarks: [{ mark: 'Lavf', count: 1, offset: 43011 }] },
      'bitstream', 'obs 档 encoder 字段里的 Lavf 是自己写的,不算违规');
    
    /* 10. profile 相符 */
    {
      const out = cleanOut();
      delete out.formatTags.encoder;
      fails({ out }, 'profile', 'obs 档该有 Lavf 版本号,却没有');
    }
    {
      const out = cleanOut();
      fails({ out, profile: 'bare' }, 'profile', 'bare 档不该有 encoder 字段,却留着');
    }
    {
      const out = cleanOut();
      out.streams[0].tags.handler_name = 'VideoHandler';
      fails({ out, profile: 'quicktime' }, 'profile', 'quicktime 档的 handler 该是 Core Media Video');
    }
    
    /* 11. 时长 */
    {
      const out = cleanOut();
      out.durationSeconds = 40;
      fails({ out }, 'duration', '输出被截短了 13 秒');
    }
    {
      const out = cleanOut();
      out.durationSeconds = 53.6;
      holds({ out }, 'duration', '差 0.23 秒在容差内,不该拦');
    }
    
    /* 12. 可解码 */
    fails({ decodeError: 'moov atom not found' }, 'decodable', '产出了打不开的坏文件');
    
    /* ------------------------------------------------------------------ */
    /* 针的挑选                                                            */
    /* ------------------------------------------------------------------ */
    {
      const { needles, skipped } = needlesOf(dirtySrc());
      const has = (s) => needles.includes(s);
      ok(has('[email protected]'), '邮箱要当针');
      ok(has('vid:v1e00fgi0000da64usvog65t9bk1rqgg'), '抖音 ID 要当针');
      ok(has('iPhone 15 Pro'), '设备名要当针');
      ok(has('+31.2304+121.4737/'), 'GPS 坐标要当针');
      ok(has('在家拍的第一段'), '章节标题要当针');
      ok(has('Lavf58.45.100'), '源片的 ffmpeg 版本号要当针——它钉死了一个版本');
      ok(has('SubtitleHandler'), 'data 轨的 handler 名要当针');
    
      ok(!has('VideoHandler'), 'VideoHandler 满世界都是,不当针');
      ok(!has('SoundHandler'), 'SoundHandler 同理');
      ok(!has('isom'), '结构性 tag 不当针,否则自己扎自己');
      ok(!has('und'), 'und 不当针');
      ok(!has('encoder'), '通用键名不当针');
      ok(skipped.every((s) => Buffer.byteLength(s, 'utf8') < DEFAULT_PARAMS.minNeedleBytes),
        '被跳过的针都短于阈值');
    }
    {
      /* 太短的串会在压缩数据里撞出假阳性,必须跳过并说明 */
      const src = dirtySrc();
      src.formatTags.artist = 'abc';
      const { needles, skipped } = needlesOf(src);
      ok(!needles.includes('abc'), '3 字节的串不扫');
      ok(skipped.includes('abc'), '不扫的要记下来,验收时在提示里说明');
      const v = run({ skippedNeedles: ['abc'] });
      ok(v.hints.some((h) => h.includes('太短')), '跳过的针要在提示里交代');
    }
    
    /* isIdentifying 的分界线 */
    {
      ok(isIdentifying('artist', '[email protected]'), '邮箱能缩小到某个人');
      ok(isIdentifying('encoder', 'Lavf58.45.100'), '版本号钉死一个版本');
      ok(!isIdentifying('handler_name', 'VideoHandler'), 'VideoHandler 信息量为零');
      ok(!isIdentifying('major_brand', 'isom'), '结构性 tag 不算');
      ok(!isIdentifying('artist', ''), '空值不算');
      ok(!isIdentifying('artist', '   '), '全空白不算');
    }
    
    /* ------------------------------------------------------------------ */
    /* SEI 这把刀什么时候不许动                                             */
    /* ------------------------------------------------------------------ */
    {
      const marks = [{ mark: 'x264 - core', count: 4, offset: 73 }];
      const sdr = dirtySrc();
      eq(seiPlan(sdr, marks).remove, true, '查到 x264 身份串就删 SEI');
      eq(seiPlan(sdr, []).remove, false, '没查到身份串就不动刀');
    
      /* HDR 的静态元数据住在 SEI 里,一刀切会掉色 */
      const hdr = dirtySrc();
      hdr.video = { ...hdr.video, colorTransfer: 'smpte2084', pixFmt: 'yuv420p10le' };
      ok(isHdr(hdr), 'smpte2084 = HDR');
      const plan = seiPlan(hdr, marks);
      eq(plan.remove, false, 'HDR 源片一律不删 SEI');
      ok(plan.warn, 'HDR 又确实有身份串时,要明说没动它');
    
      const hlg = dirtySrc();
      hlg.video = { ...hlg.video, colorTransfer: 'arib-std-b67' };
      ok(isHdr(hlg), 'HLG 也是 HDR');
      const p10 = dirtySrc();
      p10.video = { ...p10.video, pixFmt: 'p010le' };
      ok(isHdr(p10), '10bit 像素格式按 HDR 算');
      ok(!isHdr(dirtySrc()), 'yuv420p + color 全 unknown 不是 HDR');
    }
    
    /* ------------------------------------------------------------------ */
    /* ffmpeg 参数:五个藏身处一个都不许漏                                   */
    /* ------------------------------------------------------------------ */
    {
      const joined = (o) => scrubArgs({ input: 'i.mp4', output: 'o.mp4', ...o }).join(' ');
    
      const copyObs = joined({ mode: 'copy', profile: 'obs', removeSei: true });
      ok(copyObs.includes('-map 0:v:0'), '只挑视频流');
      ok(copyObs.includes('-map 0:a:0?'), '只挑音频流');
      ok(copyObs.includes('-map_metadata -1'), '不搬源片的容器 tag');
      ok(copyObs.includes('-map_chapters -1'), '不搬章节');
      ok(copyObs.includes('-c:v copy'), 'copy 模式画面不重编');
      ok(copyObs.includes('-c:a aac'), 'copy 模式音频照样重编——DSE 藏在音频码流里');
      ok(copyObs.includes('-bsf:v filter_units=remove_types=6'), '删 SEI(藏身处 4)');
      ok(copyObs.includes('-flags:a +bitexact'), '堵 AAC 的 DSE(藏身处 3)');
      ok(copyObs.includes('-metadata:s:v:0 encoder='), '清 compressorname(藏身处 2)');
      ok(copyObs.includes('-metadata:s:v:0 handler_name=VideoHandler'), '显式写 handler(藏身处 5)');
      ok(!copyObs.includes('-fflags +bitexact'), 'obs 档要留着 Lavf 版本号,不加容器 bitexact');
      ok(copyObs.includes('-metadata creation_time='), 'obs 档写创建时间');
    
      const copyBare = joined({ mode: 'copy', profile: 'bare', removeSei: true });
      ok(copyBare.includes('-fflags +bitexact'), 'bare 档要清掉容器的 encoder(藏身处 1)');
      ok(copyBare.includes('-metadata:s:v:0 handler_name= '), 'bare 档 handler 用单空格');
      ok(!copyBare.includes('-metadata creation_time='), 'bare 档什么都不写,包括时间');
    
      const enc = joined({ mode: 'encode', profile: 'bare', crf: 18 });
      ok(enc.includes('-c:v libx264'), 'encode 模式重编画面');
      ok(enc.includes('-crf 18'), 'crf 传进去了');
      ok(enc.includes('-flags:v +bitexact'), 'encode 模式要堵视频编码器的自报家门');
      ok(!enc.includes('filter_units'), '没查到身份串就不该带 SEI 过滤器');
    
      const noAudio = joined({ mode: 'copy', profile: 'obs', hasAudio: false });
      ok(!noAudio.includes('-c:a aac'), '没音频就别配音频编码器');
      ok(!noAudio.includes('-map 0:a:0?'), '没音频就别挑音频流');
      ok(!noAudio.includes('-metadata:s:a:0'), '没音频就别写音频 tag');
    
      const dated = joined({ mode: 'copy', profile: 'obs', date: '2026-01-01T00:00:00Z' });
      ok(dated.includes('-metadata creation_time=2026-01-01T00:00:00Z'), '--date 传得进去');
    
      /* 输入输出要在参数里,且输出在最后 */
      const a = scrubArgs({ input: 'in.mp4', output: 'out.mp4', mode: 'copy', profile: 'obs' });
      eq(a[a.length - 1], 'out.mp4', '输出文件在参数末尾');
      ok(a.includes('in.mp4'), '输入文件在参数里');
    }
    
    /* 乱传参数要当场报错,别让它默默跑出个错东西 */
    {
      const boom = (o, label) => {
        try { scrubArgs({ input: 'i', output: 'o', ...o }); failures.push(`${label} —— 该报错却没报`); }
        catch { passed += 1; }
      };
      boom({ profile: '不存在' }, '没有的 profile');
      boom({ mode: '不存在' }, '没有的模式');
    }
    
    /* ------------------------------------------------------------------ */
    /* 常量自洽                                                            */
    /* ------------------------------------------------------------------ */
    {
      eq(Object.keys(MODES).length, 2, '两种模式');
      eq(Object.keys(PROFILES).length, 4, '四个 profile');
      for (const [name, p] of Object.entries(PROFILES)) {
        ok(typeof p.label === 'string' && p.label.length > 0, `${name} 要有中文说明`);
        ok(typeof p.videoHandler === 'string' && p.videoHandler.length > 0, `${name} 的 videoHandler 不能为空串——置空会退回 ffmpeg 默认值`);
        ok(typeof p.audioHandler === 'string' && p.audioHandler.length > 0, `${name} 的 audioHandler 同理`);
        ok(p.expectEncoder === null || p.expectEncoder instanceof RegExp, `${name} 的 expectEncoder 要么是 null 要么是正则`);
      }
      ok(PROFILES.obs.containerBitexact === false, 'obs 档靠不加 bitexact 来保住 Lavf 版本号');
      ok(PROFILES.bare.containerBitexact === true, 'bare 档必须清掉容器 encoder');
      ok(TOOL_MARKS.includes('x264 - core'), '工具指纹表里要有 x264');
      ok(TOOL_MARKS.includes('Lavc'), '工具指纹表里要有 Lavc');
      ok(STRUCTURAL_TAGS.has('major_brand'), 'major_brand 是结构性 tag');
      ok(GENERIC_STRINGS.has('VideoHandler'), 'VideoHandler 是通用串');
      ok(LOCATION_KEYS.length > 0 && DEVICE_KEYS.includes('comment'), 'comment 算设备/账号标识——抖音 ID 就写在那儿');
      eq(DEFAULT_PARAMS.mode, 'copy', '默认 copy 模式');
      eq(DEFAULT_PARAMS.profile, 'obs', '默认 obs 档');
      ok(DEFAULT_PARAMS.minNeedleBytes >= 4, '针的最短长度要挡住压缩数据里的随机碰撞');
    }
    
    /* ------------------------------------------------------------------ */
    
    if (failures.length) {
      process.stderr.write(`\n${failures.length} 项没过:\n`);
      for (const f of failures) process.stderr.write(`  ✗ ${f}\n`);
      process.stderr.write(`\n通过 ${passed}/${passed + failures.length}\n`);
      process.exitCode = 1;
    } else {
      process.stdout.write(`✅ ${passed} 项断言全部通过(12 道门每道都有击穿用例)\n`);
    }
    
  • skills/video-scrub/scripts/video-scrub.mjs31 KB05b30e17d885upstream ↗
    #!/usr/bin/env node
    // video-scrub — 把一条视频重建成「只有画面和声音」的干净文件,源片的元数据一概不搬。
    // 零 npm 依赖。需要 node >= 18、ffmpeg/ffprobe。
    
    import { execFileSync } from 'node:child_process';
    import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
    import { basename } from 'node:path';
    import { fileURLToPath } from 'node:url';
    
    /* ------------------------------------------------------------------ */
    /* 原理                                                                */
    /* ------------------------------------------------------------------ */
    /*
     * 清元数据有两种思路,这里只用后一种:
     *
     *   黑名单——列出要删的字段逐个删。**删不完你不知道的东西**:厂商私有的 udta、
     *            GoPro 的遥测轨、码流里的 SEI,漏一个就漏了。
     *   白名单——不说删什么,只说带什么过去:**画面一条流、声音一条流,别的一律不要**。
     *            源片的元数据没有任何通道能进来。隐私保证来自结构,不来自枚举。
     *
     * 但 ffmpeg 默认会背叛这个结构两次,必须摁住:
     *
     *   1. 它默认把源片的容器 tag 搬到输出   → -map_metadata -1
     *   2. 它默认自动挑流,会把 GoPro 的 gpmd 遥测轨一起带走 → -map 0:v:0 -map 0:a:0?
     *
     * 摁住之后文件是「无名」的,profile 决定往回写什么(见 PROFILES)。
     *
     * 然后 ffmpeg 会把**自己的**身份写进五个地方,ffprobe 只看得见第一处,
     * 全部堵法见 references/residue-map.md。
     */
    
    export const MODES = {
      // copy 模式下**画面逐字节照搬**(实测:抽出的 H.264 码流与源片 cmp 一致),
      // 但音频必须重编一遍——ffmpeg 的 AAC 把自己的版本号写在 DSE 里,那是码流内部,
      // 不重编就抹不掉。音频重编很便宜,几十秒的片子不到一秒。
      copy: '画面逐字节照搬、只重编音频:画质零损失、快几十倍,元数据一样清干净',
      encode: '完整重编码:像素重算,连码流域的东西也一并没了,代价是有损 + 慢',
    };
    
    /**
     * profile:擦白之后往回写的那一层。
     *
     * 有一件事 ffmpeg 不让做:容器的 `encoder` 字段由 muxer 自己占着,
     * `-metadata encoder=Lavf60.16.100` 盖不过去,置空也清不掉(实测)。
     * 只有 `-fflags +bitexact` 能让它整个消失。所以 obs 档不伪造版本号——
     * 它就让 ffmpeg 写自己的真版本号,反正 OBS 产出的本来也是 ffmpeg 封装的文件,
     * 两者同类。其余档一律 bitexact,连这个字段都不留。
     */
    export const PROFILES = {
      obs: {
        label: 'OBS Studio 录制',
        containerBitexact: false,        // 留着 ffmpeg 自己的 Lavf 版本号
        expectEncoder: /^Lavf\d+\./,
        videoHandler: 'VideoHandler',
        audioHandler: 'SoundHandler',
        setCreationTime: true,
      },
      quicktime: {
        label: 'macOS QuickTime 录屏',
        containerBitexact: true,
        expectEncoder: null,
        videoHandler: 'Core Media Video',
        audioHandler: 'Core Media Audio',
        setCreationTime: true,
      },
      screencapture: {
        label: 'macOS ScreenCaptureKit 录屏',
        containerBitexact: true,
        expectEncoder: null,
        videoHandler: 'Core Media Video',
        audioHandler: 'Core Media Audio',
        setCreationTime: true,
      },
      bare: {
        label: '无名——什么都不写',
        // 隐私强度最高:不写任何可被证伪的声明。handler 用单空格,置空会退回 ffmpeg 默认值。
        containerBitexact: true,
        expectEncoder: null,
        videoHandler: ' ',
        audioHandler: ' ',
        setCreationTime: false,
      },
    };
    
    export const DEFAULT_PARAMS = {
      mode: 'copy',
      profile: 'obs',
      crf: 18,               // 只在 encode 模式用
      minNeedleBytes: 5,     // 针短于它就不扫:压缩数据里会随机撞出假阳性
      durationTolerance: 0.5,
    };
    
    /**
     * 结构性 tag:描述容器怎么组装的,不是隐私,也不当「针」。
     * major_brand 这种值输出里必然还会出现,拿它当针会自己扎自己。
     */
    export const STRUCTURAL_TAGS = new Set([
      'major_brand', 'minor_version', 'compatible_brands', 'language',
    ]);
    
    /**
     * 通用串:**这一类工具产出的每个文件里都有**,识别不出任何人、任何设备、任何账号。
     *
     * 它们既不当针,也不算 tag 层残留——否则 obs 档写回 `VideoHandler` 会被自己的门拦下,
     * 而那个字符串的信息量是零。分界线:能不能把范围缩小到某个人、某台设备、某次导出。
     * `Lavf58.45.100` 能(它钉死了一个版本),`VideoHandler` 不能(满世界都是)。
     */
    export const GENERIC_STRINGS = new Set([
      'VideoHandler', 'SoundHandler', 'DataHandler',
      'Core Media Video', 'Core Media Audio', 'Core Media Data',
      'handler_name', 'encoder', 'language', 'und', 'eng',
    ]);
    
    /** 这个键值对能不能把范围缩小到某个人/设备/某次导出。 */
    export function isIdentifying(key, value) {
      const k = String(key ?? '').toLowerCase();
      if (STRUCTURAL_TAGS.has(k)) return false;
      const v = String(value ?? '').trim();
      if (!v) return false;
      return !GENERIC_STRINGS.has(v);
    }
    
    /** 已知的工具身份串。码流层查到这些 = 有编码器把自己的名字写进去了。 */
    export const TOOL_MARKS = [
      'x264 - core', 'x265', 'Lavc', 'Lavf', 'libavcodec', 'libavformat',
      'HandBrake', 'Xvid', 'DivX',
    ];
    
    /** 位置类字段:一个都不许有。 */
    export const LOCATION_KEYS = [
      'location', 'location-eng', 'com.apple.quicktime.location.iso6109',
      'com.apple.quicktime.location.iso6709', 'gps', 'gpslatitude', 'gpslongitude',
      'gpscoordinates', 'xyz', '©xyz',
    ];
    
    /** 设备与软件类字段:泄露你用什么拍的、什么账号导的。 */
    export const DEVICE_KEYS = [
      'make', 'model', 'software', 'com.apple.quicktime.make',
      'com.apple.quicktime.model', 'com.apple.quicktime.software',
      'com.android.version', 'device', 'artist', 'author', 'copyright',
      'comment', 'description', 'title', 'album', 'composer', 'performer',
      'encoded_by', 'creation_time', 'date',
    ];
    
    const r2 = (n) => Math.round(n * 100) / 100;
    
    /* ------------------------------------------------------------------ */
    /* 探测                                                                */
    /* ------------------------------------------------------------------ */
    
    /** ffprobe 全量:format / streams / chapters,一次拿全。 */
    export function probe(file) {
      const out = execFileSync('ffprobe', [
        '-v', 'error', '-print_format', 'json',
        '-show_format', '-show_streams', '-show_chapters',
        file,
      ], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
      const j = JSON.parse(out);
      const streams = j.streams ?? [];
      const video = streams.find((s) => s.codec_type === 'video') ?? null;
      return {
        file,
        durationSeconds: r2(Number(j.format?.duration ?? 0)),
        sizeBytes: Number(j.format?.size ?? 0),
        formatTags: j.format?.tags ?? {},
        chapters: j.chapters ?? [],
        streams: streams.map((s) => ({
          index: s.index,
          type: s.codec_type,
          codec: s.codec_name ?? null,
          tags: s.tags ?? {},
          sideData: s.side_data_list ?? [],
        })),
        hasAudio: streams.some((s) => s.codec_type === 'audio'),
        video: video ? {
          width: video.width ?? 0,
          height: video.height ?? 0,
          pixFmt: video.pix_fmt ?? null,
          colorSpace: video.color_space ?? null,
          colorTransfer: video.color_transfer ?? null,
          colorPrimaries: video.color_primaries ?? null,
        } : null,
      };
    }
    
    /**
     * 源片是不是 HDR。**删 SEI 之前必须问这一句**:HDR 的静态元数据
     * (mastering display / content light level)就住在 SEI 里,一刀切会让片子掉色。
     */
    export function isHdr(p) {
      const v = p.video;
      if (!v) return false;
      const hdrTransfers = ['smpte2084', 'arib-std-b67', 'smpte428', 'bt2020-10', 'bt2020-12'];
      const hdrPrimaries = ['bt2020'];
      return hdrTransfers.includes(String(v.colorTransfer))
        || hdrPrimaries.includes(String(v.colorPrimaries))
        || /10le|12le|p010|p210/.test(String(v.pixFmt));
    }
    
    /**
     * 从源片挖出所有「针」:tag 的键和值、handler 名、章节标题。
     * 这些字符串**一个都不该出现在输出里**——验收时拿它们去扫输出的字节。
     */
    export function needlesOf(p, params = DEFAULT_PARAMS) {
      const min = params.minNeedleBytes ?? DEFAULT_PARAMS.minNeedleBytes;
      const raw = new Set();
      const push = (k, v) => {
        if (!isIdentifying(k, v)) return;
        if (k && !GENERIC_STRINGS.has(String(k))) raw.add(String(k));
        raw.add(String(v));
      };
      for (const [k, v] of Object.entries(p.formatTags)) push(k, v);
      for (const s of p.streams) for (const [k, v] of Object.entries(s.tags)) push(k, v);
      for (const c of p.chapters) {
        if (c?.tags?.title) raw.add(String(c.tags.title));
      }
      const needles = [];
      const skipped = [];
      for (const s of raw) {
        (Buffer.byteLength(s, 'utf8') >= min ? needles : skipped).push(s);
      }
      return { needles: needles.sort(), skipped: skipped.sort() };
    }
    
    /**
     * 字节级扫描:把针一根根在文件里找。
     *
     * **这是整套东西的骨气所在**——前面全是「我调了正确的参数」,属于声称;
     * 这一步是「我扫了,真没了」,属于证明。
     */
    export function scanBytes(file, needles) {
      const buf = readFileSync(file);
      const hits = [];
      for (const n of needles) {
        const pat = Buffer.from(n, 'utf8');
        if (pat.length === 0) continue;
        let from = 0;
        let count = 0;
        let first = -1;
        for (;;) {
          const i = buf.indexOf(pat, from);
          if (i === -1) break;
          if (first === -1) first = i;
          count += 1;
          from = i + 1;
          if (count > 64) break;
        }
        if (count) hits.push({ needle: n, count, offset: first });
      }
      return hits;
    }
    
    /** 扫码流里的工具身份串(SEI / DSE / compressorname 都在这一层)。 */
    export function scanToolMarks(file) {
      const buf = readFileSync(file);
      const hits = [];
      for (const m of TOOL_MARKS) {
        const pat = Buffer.from(m, 'utf8');
        let from = 0;
        let count = 0;
        let first = -1;
        for (;;) {
          const i = buf.indexOf(pat, from);
          if (i === -1) break;
          if (first === -1) first = i;
          count += 1;
          from = i + 1;
          if (count > 64) break;
        }
        if (count) hits.push({ mark: m, count, offset: first });
      }
      return hits;
    }
    
    /**
     * 要不要动 SEI 这把刀。
     *
     * ffmpeg 只给得起 NAL 级的粒度(`filter_units` 按 NAL 类型删,
     * `h264_metadata` 也没有「只删某个 SEI payload」的选项),所以 remove_types=6
     * 是**全部 SEI 一起删**。SEI 里除了 x264 那串垃圾,还住着 HDR 元数据和
     * CEA-608/708 内嵌字幕——所以只在**真查到身份串**时才动刀,HDR 源片一律不动。
     */
    export function seiPlan(p, toolMarks) {
      const identity = toolMarks.filter((h) => h.mark === 'x264 - core' || h.mark === 'x265');
      if (isHdr(p)) {
        return {
          remove: false,
          reason: 'HDR 源片:SEI 里住着 mastering display / content light level,删了会掉色',
          warn: identity.length > 0
            ? `码流里有 ${identity.map((h) => h.mark).join('、')},但 HDR 优先,没动它`
            : null,
        };
      }
      if (!identity.length) {
        return { remove: false, reason: '码流里没查到编码器身份串,不必动刀', warn: null };
      }
      return {
        remove: true,
        reason: `码流里有 ${identity.map((h) => `${h.mark}(${h.count} 处)`).join('、')}`,
        warn: null,
      };
    }
    
    /* ------------------------------------------------------------------ */
    /* 构造 ffmpeg 参数                                                     */
    /* ------------------------------------------------------------------ */
    
    /**
     * 纯函数:只拼参数,不跑 ffmpeg。自测靠它,不花时间不碰真文件。
     *
     * 五个藏身处对应的堵法都在这里,少一条就不算清干净:
     *   1. 容器 tag 的 Lavf   → -fflags +bitexact(profile 要写 encoder 的话再显式写回)
     *   2. avc1 的 compressorname → -metadata:s:v:0 encoder=
     *   3. AAC 码流的 DSE      → -flags:a +bitexact
     *   4. H.264 的 SEI        → -bsf:v filter_units=remove_types=6
     *   5. handler_name        → 显式写值,置空会退回 ffmpeg 默认的 VideoHandler
     */
    export function scrubArgs(opts) {
      const {
        input, output,
        mode = DEFAULT_PARAMS.mode,
        profile = DEFAULT_PARAMS.profile,
        crf = DEFAULT_PARAMS.crf,
        encoder = 'libx264',
        hasAudio = true,
        removeSei = false,
        date = null,
      } = opts;
    
      const prof = PROFILES[profile];
      if (!prof) throw new Error(`没有 ${profile} 这个 profile(有 ${Object.keys(PROFILES).join(' / ')})`);
      if (!MODES[mode]) throw new Error(`没有 ${mode} 这个模式(有 ${Object.keys(MODES).join(' / ')})`);
    
      const a = ['-v', 'error', '-y', '-i', input];
    
      // ① 白名单选流:只要画面和声音,data / timecode / 附件 / 章节一律不带
      a.push('-map', '0:v:0');
      if (hasAudio) a.push('-map', '0:a:0?');
      a.push('-map_metadata', '-1', '-map_chapters', '-1');
    
      // ② 编解码
      if (mode === 'copy') {
        a.push('-c:v', 'copy');
      } else {
        a.push('-c:v', encoder);
        if (encoder === 'libx264' || encoder === 'libx265') a.push('-crf', String(crf));
        else a.push('-b:v', '0', '-q:v', '55');
        a.push('-pix_fmt', 'yuv420p');
      }
      // 音频**两种模式都重编**:AAC 的版本号写在 DSE 里,那是码流内部,
      // -c:a copy 抹不掉它。重编一遍很便宜,换来音轨里干干净净。
      if (hasAudio) a.push('-c:a', 'aac', '-b:a', '192k');
    
      // ③ 码流里的 SEI(藏身处 4)——只在查到身份串时才删,见 seiPlan。
      //    实测它在 -c:v copy 下照样工作,所以 copy 模式一样清得掉 x264 那串。
      if (removeSei) a.push('-bsf:v', 'filter_units=remove_types=6');
    
      // ④ 让 ffmpeg 闭嘴(藏身处 1、3)
      //    容器的 encoder 字段只有 bitexact 清得掉,但 obs 档要留着它,见 PROFILES 注释。
      //    显式写的 creation_time 不受 bitexact 影响,实测过。
      if (prof.containerBitexact) a.push('-fflags', '+bitexact');
      if (mode === 'encode') a.push('-flags:v', '+bitexact');
      if (hasAudio) a.push('-flags:a', '+bitexact');
    
      // ⑤ compressorname(藏身处 2):mov muxer 从流的 encoder tag 取这个字段,置空即清
      a.push('-metadata:s:v:0', 'encoder=');
      if (hasAudio) a.push('-metadata:s:a:0', 'encoder=');
    
      // ⑥ profile 往回写的那一层(藏身处 5 也在这里)
      a.push('-metadata:s:v:0', `handler_name=${prof.videoHandler}`);
      if (hasAudio) a.push('-metadata:s:a:0', `handler_name=${prof.audioHandler}`);
      if (prof.setCreationTime) {
        a.push('-metadata', `creation_time=${date ?? new Date().toISOString()}`);
      }
    
      a.push('-movflags', '+faststart', output);
      return a;
    }
    
    /* ------------------------------------------------------------------ */
    /* 门                                                                  */
    /* ------------------------------------------------------------------ */
    
    const GATE_LABELS = {
      residue: '字节级残留',
      tags: 'tag 层残留',
      gps: '位置信息',
      device: '设备与软件标识',
      creation: '源片时间戳',
      rotation: '旋转矩阵',
      streams: '流构成',
      chapters: '章节',
      bitstream: '码流身份串',
      profile: 'profile 相符',
      duration: '时长',
      decodable: '可解码',
    };
    
    const gate = (id, issues, skipped = null) => ({
      id,
      label: GATE_LABELS[id] ?? id,
      ok: skipped ? true : issues.length === 0,
      skipped,
      issues,
    });
    
    /**
     * 纯函数:吃探测结果,吐门的清单。不做 IO,自测可以直接喂假数据。
     */
    export function verify(ctx) {
      const {
        src, out, residue = [], toolMarks = [],
        profile = DEFAULT_PARAMS.profile,
        mode = DEFAULT_PARAMS.mode,
        params = DEFAULT_PARAMS,
        skippedNeedles = [],
        decodeError = null,
      } = ctx;
      const prof = PROFILES[profile];
      const gates = [];
      const hints = [];
    
      /*
       * profile 自己写上去的值要豁免,否则会出现一种假阳性:
       * 源片也是 ffmpeg 封的、版本号还恰好相同,那输出的 encoder 会和源片一模一样——
       * 但它是 muxer 现写的,不是漏过来的。
       *
       * 这个豁免不会开口子:有 `-map_metadata -1` 在,源片的 encoder 字段
       * **结构上就到不了**输出,那一格永远由 muxer 自己填。
       */
      const profileOwned = new Set();
      if (prof?.expectEncoder) {
        const enc = String(out.formatTags.encoder ?? '');
        if (prof.expectEncoder.test(enc)) profileOwned.add(enc);
      }
    
      /* 1. 字节级残留:源片的元数据串一根都不许扎中 */
      {
        const real = residue.filter((h) => !profileOwned.has(h.needle));
        const bad = real.map((h) => `「${h.needle}」在输出里出现 ${h.count} 次(首现 @${h.offset})`);
        gates.push(gate('residue', bad));
        const exempt = residue.length - real.length;
        if (exempt) hints.push(`有 ${exempt} 个串是 ${profile} 档自己写回去的(muxer 现写,非源片残留),已豁免`);
        if (skippedNeedles.length) {
          hints.push(`有 ${skippedNeedles.length} 个太短的串没扫(短于 ${params.minNeedleBytes} 字节会在压缩数据里撞出假阳性):${skippedNeedles.join('、')}`);
        }
      }
    
      /* 2. tag 层:输出的键和值都不许来自源片 */
      {
        const srcVals = new Set();
        const collect = (tags) => {
          for (const [k, v] of Object.entries(tags)) {
            if (isIdentifying(k, v)) srcVals.add(String(v));
          }
        };
        collect(src.formatTags);
        for (const s of src.streams) collect(s.tags);
    
        const bad = [];
        const checkOut = (tags, where) => {
          for (const [k, v] of Object.entries(tags)) {
            if (!isIdentifying(k, v) || profileOwned.has(String(v))) continue;
            if (srcVals.has(String(v))) bad.push(`${where} 的 ${k} = ${v}(源片里就有这个值)`);
          }
        };
        checkOut(out.formatTags, 'format');
        for (const s of out.streams) checkOut(s.tags, `stream #${s.index}`);
        gates.push(gate('tags', bad));
      }
    
      /* 3. 位置:一个都不许有 */
      {
        const bad = [];
        const scan = (tags, where) => {
          for (const k of Object.keys(tags)) {
            const low = k.toLowerCase();
            if (LOCATION_KEYS.some((g) => low === g || low.includes('location') || low.includes('gps'))) {
              bad.push(`${where} 还留着 ${k}`);
            }
          }
        };
        scan(out.formatTags, 'format');
        for (const s of out.streams) scan(s.tags, `stream #${s.index}`);
        gates.push(gate('gps', bad));
      }
    
      /* 4. 设备与软件:profile 自己要写的除外 */
      {
        const allowed = new Set();
        if (prof?.expectEncoder) allowed.add('encoder');
        if (prof?.setCreationTime) allowed.add('creation_time');
        const bad = [];
        for (const k of Object.keys(out.formatTags)) {
          const low = k.toLowerCase();
          if (STRUCTURAL_TAGS.has(low) || allowed.has(low)) continue;
          if (DEVICE_KEYS.includes(low)) bad.push(`format 还留着 ${k} = ${out.formatTags[k]}`);
        }
        gates.push(gate('device', bad));
      }
    
      /* 5. 源片时间戳:输出的 creation_time 不许等于源片的 */
      {
        const srcTime = src.formatTags.creation_time
          ?? src.streams.map((s) => s.tags.creation_time).find(Boolean);
        const outTime = out.formatTags.creation_time
          ?? out.streams.map((s) => s.tags.creation_time).find(Boolean);
        const bad = [];
        if (srcTime && outTime && String(srcTime) === String(outTime)) {
          bad.push(`输出的 creation_time 和源片一模一样:${outTime}`);
        }
        gates.push(gate('creation', bad));
      }
    
      /* 6. 旋转矩阵。copy 模式下画面字节没动,矩阵必须留着,否则播出来是歪的 */
      {
        const rot = out.streams.flatMap((s) => s.sideData.filter((d) => /display ?matrix/i.test(String(d.side_data_type ?? ''))));
        if (mode === 'copy') {
          gates.push(gate('rotation', [], 'copy 模式:画面未重编,旋转矩阵必须原样留着'));
        } else {
          gates.push(gate('rotation', rot.length ? ['输出还带着 display matrix,说明旋转没烘进画面'] : []));
        }
      }
    
      /* 7. 流构成:只剩画面和声音。GoPro 的 GPS 轨就死在这一条 */
      {
        const bad = [];
        const byType = {};
        for (const s of out.streams) byType[s.type] = (byType[s.type] ?? 0) + 1;
        for (const [t, n] of Object.entries(byType)) {
          if (t !== 'video' && t !== 'audio') bad.push(`输出里还有 ${n} 条 ${t} 流`);
        }
        if ((byType.video ?? 0) !== 1) bad.push(`视频流应为 1 条,实际 ${byType.video ?? 0} 条`);
        if ((byType.audio ?? 0) > 1) bad.push(`音频流最多 1 条,实际 ${byType.audio} 条`);
        gates.push(gate('streams', bad));
      }
    
      /* 8. 章节 */
      gates.push(gate('chapters', out.chapters.length ? [`输出还有 ${out.chapters.length} 个章节`] : []));
    
      /* 9. 码流身份串:profile 明说要写的不算 */
      {
        // obs 档明说要留着 ffmpeg 自己的 Lavf 版本号,那一处不算违规。
        const declared = prof?.expectEncoder ? String(out.formatTags.encoder ?? '') : '';
        const bad = toolMarks
          .filter((h) => !(declared && declared.includes(h.mark)))
          .map((h) => `码流里有「${h.mark}」${h.count} 处(首现 @${h.offset})`);
        gates.push(gate('bitstream', bad));
      }
    
      /* 10. 剩下的 tag 恰好等于 profile 声明的 */
      {
        const bad = [];
        const enc = String(out.formatTags.encoder ?? '');
        if (prof?.expectEncoder && !prof.expectEncoder.test(enc)) {
          bad.push(`profile 说 encoder 该长得像 ${prof.expectEncoder},实际是「${enc || '(没有)'}」`);
        }
        if (prof && !prof.expectEncoder && enc) {
          bad.push(`profile 说不该有 encoder 字段,实际留着「${enc}」`);
        }
        const vh = out.streams.find((s) => s.type === 'video')?.tags?.handler_name ?? '';
        if (prof && String(vh).trim() !== String(prof.videoHandler).trim()) {
          bad.push(`视频 handler_name 该是「${prof.videoHandler.trim() || '(空)'}」,实际「${vh}」`);
        }
        gates.push(gate('profile', bad));
      }
    
      /* 11. 时长:没被偷偷截断 */
      {
        const d = Math.abs(out.durationSeconds - src.durationSeconds);
        const tol = params.durationTolerance ?? DEFAULT_PARAMS.durationTolerance;
        gates.push(gate('duration', d > tol
          ? [`输出 ${out.durationSeconds}s,源片 ${src.durationSeconds}s,差 ${r2(d)}s(容差 ${tol}s)`]
          : []));
      }
    
      /* 12. 能不能正常解码 */
      gates.push(gate('decodable', decodeError ? [`解码报错:${decodeError}`] : []));
    
      const failed = gates.filter((g) => !g.ok);
      return { gates, failed, hints, ok: failed.length === 0 };
    }
    
    /** 整条流水线跑完解码一遍,确认没产出坏文件。 */
    export function decodeCheck(file) {
      try {
        execFileSync('ffmpeg', ['-v', 'error', '-i', file, '-f', 'null', '-'],
          { stdio: ['ignore', 'ignore', 'pipe'], encoding: 'utf8' });
        return null;
      } catch (err) {
        const msg = String(err.stderr ?? err.message).trim().split('\n')[0];
        return msg || '未知错误';
      }
    }
    
    /* ------------------------------------------------------------------ */
    /* CLI                                                                 */
    /* ------------------------------------------------------------------ */
    
    const USAGE = `video-scrub.mjs — 重建一条视频,源片的元数据一概不搬
    
      inspect <video> [--json]
          先看源片带了什么:容器 tag、流 tag、side data、章节,
          以及 **ffprobe 看不见的那层**——码流里的 SEI / DSE 身份串。
    
      scrub <video> [-o out.mp4] [--mode copy|encode] [--profile obs|quicktime|screencapture|bare]
            [--crf 18] [--encoder libx264] [--date <ISO 时间>]
          清。默认 --mode copy(画质零损失、快几十倍)+ --profile obs。
          --mode encode 会重编码,多杀掉码流域的东西,代价是有损。
    
      verify <源> <输出> [--profile obs] [--mode copy] [--json]
          验收:把源片所有元数据串当针,在输出的字节里扫一遍,扎到一根就红。
          12 道门的清单。
    
      run <video> [-o out.mp4] [其余同 scrub]
          scrub + verify 一条龙。**日常就用这个。**
    
    模式:
      copy    ${MODES.copy}
      encode  ${MODES.encode}
    
    profile:
    ${Object.entries(PROFILES).map(([k, v]) => `  ${k.padEnd(14)}${v.label}`).join('\n')}
    `;
    
    function flag(rest, name, fallback = null) {
      const i = rest.indexOf(name);
      if (i === -1) return fallback;
      const v = rest[i + 1];
      return v == null || v.startsWith('--') ? true : v;
    }
    
    function has(rest, name) {
      return rest.includes(name);
    }
    
    function needInput(rest) {
      const file = rest.find((a) => !a.startsWith('-') && existsSync(a));
      if (!file) throw new Error('要给一个存在的视频文件');
      return file;
    }
    
    function optsOf(rest, input) {
      const mode = String(flag(rest, '--mode', DEFAULT_PARAMS.mode));
      const profile = String(flag(rest, '--profile', DEFAULT_PARAMS.profile));
      if (!MODES[mode]) throw new Error(`没有 ${mode} 这个模式(有 ${Object.keys(MODES).join(' / ')})`);
      if (!PROFILES[profile]) throw new Error(`没有 ${profile} 这个 profile(有 ${Object.keys(PROFILES).join(' / ')})`);
      const base = basename(input).replace(/\.[^.]+$/, '');
      return {
        mode,
        profile,
        crf: Number(flag(rest, '--crf', DEFAULT_PARAMS.crf)),
        encoder: String(flag(rest, '--encoder', 'libx264')),
        date: flag(rest, '--date', null),
        output: String(flag(rest, '-o', null) ?? flag(rest, '--out', null) ?? `${base}-scrubbed.mp4`),
      };
    }
    
    function cmdInspect(rest) {
      const file = needInput(rest);
      const p = probe(file);
      const marks = scanToolMarks(file);
      const { needles, skipped } = needlesOf(p);
      const report = {
        file, durationSeconds: p.durationSeconds, sizeBytes: p.sizeBytes,
        hdr: isHdr(p),
        formatTags: p.formatTags,
        streams: p.streams.map((s) => ({ index: s.index, type: s.type, codec: s.codec, tags: s.tags, sideData: s.sideData.map((d) => d.side_data_type) })),
        chapters: p.chapters.length,
        toolMarks: marks,
        needles, skippedNeedles: skipped,
      };
      if (has(rest, '--json')) {
        process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
        return report;
      }
      const L = (s) => process.stdout.write(`${s}\n`);
      L(`${file} ${p.durationSeconds}s ${(p.sizeBytes / 1e6).toFixed(1)}MB ${p.video?.width}x${p.video?.height}${isHdr(p) ? ' ⚠ HDR' : ''}`);
      L('');
      L('容器 tag:');
      const ft = Object.entries(p.formatTags);
      if (!ft.length) L('  (空)');
      for (const [k, v] of ft) L(`  ${STRUCTURAL_TAGS.has(k.toLowerCase()) ? ' ' : '!'} ${k} = ${v}`);
      L('');
      L('流:');
      for (const s of p.streams) {
        L(`  #${s.index} ${s.type}/${s.codec}${s.type !== 'video' && s.type !== 'audio' ? ' ← 这条不会被带过去' : ''}`);
        for (const [k, v] of Object.entries(s.tags)) L(`      ${k} = ${v}`);
        for (const d of s.sideData) L(`      side_data: ${d.side_data_type}`);
      }
      if (p.chapters.length) L(`\n章节:${p.chapters.length} 个`);
      L('');
      L('码流里的身份串(ffprobe 看不见这一层):');
      if (!marks.length) L('  (干净)');
      for (const m of marks) L(`  ! 「${m.mark}」${m.count} 处,首现 @${m.offset}`);
      L('');
      L(`验收会拿 ${needles.length} 个串当针去扫输出${skipped.length ? `(另有 ${skipped.length} 个太短,不扫)` : ''}`);
      const plan = seiPlan(p, marks);
      L(`SEI:${plan.remove ? '会删' : '不动'}——${plan.reason}`);
      if (plan.warn) L(`  ⚠ ${plan.warn}`);
      return report;
    }
    
    function cmdScrub(rest) {
      const input = needInput(rest);
      const o = optsOf(rest, input);
      const p = probe(input);
      const marks = scanToolMarks(input);
      const plan = seiPlan(p, marks);
    
      const args = scrubArgs({
        input, output: o.output, mode: o.mode, profile: o.profile,
        crf: o.crf, encoder: o.encoder, hasAudio: p.hasAudio,
        removeSei: plan.remove, date: o.date,
      });
    
      process.stderr.write(`${o.mode} / ${o.profile} ${input} → ${o.output}\n`);
      process.stderr.write(`SEI:${plan.remove ? '删' : '不动'}——${plan.reason}\n`);
      if (plan.warn) process.stderr.write(`⚠ ${plan.warn}\n`);
    
      const t0 = Date.now();
      execFileSync('ffmpeg', args, { stdio: ['ignore', 'ignore', 'inherit'] });
      const secs = ((Date.now() - t0) / 1000).toFixed(1);
      const outSize = statSync(o.output).size;
      process.stderr.write(`完成 ${secs}s ${(outSize / 1e6).toFixed(1)}MB(源片 ${(p.sizeBytes / 1e6).toFixed(1)}MB)\n`);
      return o.output;
    }
    
    function cmdVerify(rest) {
      const files = rest.filter((a) => !a.startsWith('-') && existsSync(a));
      if (files.length < 2) throw new Error('要给两个文件:verify <源> <输出>');
      const [srcFile, outFile] = files;
      const mode = String(flag(rest, '--mode', DEFAULT_PARAMS.mode));
      const profile = String(flag(rest, '--profile', DEFAULT_PARAMS.profile));
    
      const src = probe(srcFile);
      const out = probe(outFile);
      const { needles, skipped } = needlesOf(src);
      const residue = scanBytes(outFile, needles);
      const toolMarks = scanToolMarks(outFile);
      const decodeError = decodeCheck(outFile);
    
      const v = verify({ src, out, residue, toolMarks, profile, mode, skippedNeedles: skipped, decodeError });
    
      if (has(rest, '--json')) {
        process.stdout.write(`${JSON.stringify({ ...v, residue, toolMarks }, null, 2)}\n`);
        return v;
      }
      const L = (s) => process.stdout.write(`${s}\n`);
      L(`${basename(srcFile)} → ${basename(outFile)} ${mode} / ${profile}`);
      L(`扫了 ${needles.length} 根针`);
      L('');
      for (const g of v.gates) {
        const mark = g.skipped ? '–' : g.ok ? '✓' : '✗';
        L(`  ${mark} ${g.label}${g.skipped ? ` (跳过:${g.skipped})` : ''}`);
        for (const i of g.issues) L(`      ${i}`);
      }
      for (const h of v.hints) L(`\n  提示:${h}`);
      L('');
      L(v.ok ? `✅ ${v.gates.length} 道门全过——源片的元数据一个字节都没剩下` : `❌ ${v.failed.length} 道门红了`);
      if (!v.ok) process.exitCode = 1;
      return v;
    }
    
    function cmdRun(rest) {
      const input = needInput(rest);
      const o = optsOf(rest, input);
      cmdScrub(rest);
      process.stderr.write('\n');
      return cmdVerify([input, o.output, '--mode', o.mode, '--profile', o.profile, ...(has(rest, '--json') ? ['--json'] : [])]);
    }
    
    export function main(argv) {
      const [cmd, ...rest] = argv;
      switch (cmd) {
        case 'inspect': return cmdInspect(rest);
        case 'scrub': return cmdScrub(rest);
        case 'verify': return cmdVerify(rest);
        case 'run': return cmdRun(rest);
        default:
          process.stdout.write(USAGE);
          if (cmd && cmd !== '--help' && cmd !== '-h') process.exitCode = 1;
          return undefined;
      }
    }
    
    function isMainModule() {
      if (!process.argv[1]) return false;
      try {
        return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
      } catch {
        return false;
      }
    }
    
    if (isMainModule()) {
      process.stdout.on('error', (err) => { if (err.code === 'EPIPE') process.exit(0); });
      try {
        main(process.argv.slice(2));
      } catch (err) {
        process.stderr.write(`${err.message}\n`);
        process.exitCode = 1;
      }
    }
    
  • skills/video-scrub/references/profiles.md3.1 KB6b837044398eupstream ↗
    # profile:擦白之后写回去的那一层
    
    清完之后文件是「无名」的——没有 tag,没有 handler 名,没有时间。
    profile 决定往回写什么。
    
    **隐私强度排序:`bare` > 其余三档。** 理由很简单:`bare` 不写任何可被证伪的声明。
    其余三档写的是工具类信息(什么软件封装的、什么 handler),**不编造拍摄设备、不编造位置**。
    
    ---
    
    ## 录屏的元数据长什么样
    
    先说一个事实,它决定了这几档为什么都这么简单:
    
    **录屏的元数据特征九成是「没有」。**
    
    GPS 是拍摄设备的定位服务写进去的——iPhone 相机写 `com.apple.quicktime.location.ISO6709`,
    安卓相机写 `location`。录屏抓的是显示缓冲区,QuickTime、ScreenCaptureKit、OBS、
    Windows Game Bar、iOS 控制中心录屏,**压根没有定位这条管线,也没有相应权限**。
    
    所以一条录屏文件里不会有:GPS、相机型号、镜头光圈快门、旋转矩阵、拍摄参数。
    剩下的只有封装工具的痕迹。
    
    ---
    
    ## 四档
    
    ### `obs`(默认)—— OBS Studio 录制
    
    ```
    encoder      = Lavf<ffmpeg 的真版本号>
    handler_name = VideoHandler / SoundHandler
    creation_time = <当前时间或 --date>
    ```
    
    **这档不是伪造。** OBS 本来就是用 ffmpeg 封装输出的,所以它产出的文件带 `Lavf` 版本号、
    带标准 handler 名。我们的输出也是 ffmpeg 封的,长相同类。
    
    版本号**不伪造**——做不到(见 `residue-map.md` 第 1 条),也没必要。
    这一档靠**不加** `-fflags +bitexact` 来保住 ffmpeg 自己写的版本号。
    
    ### `quicktime` —— macOS QuickTime 录屏
    
    ```
    handler_name = Core Media Video / Core Media Audio
    creation_time = <当前时间或 --date>
    (无 encoder 字段)
    ```
    
    `Core Media *` 是 Apple 的 AVFoundation 写的 handler 名,QuickTime 录屏、
    iOS 录屏产出的文件都长这样。
    
    ### `screencapture` —— macOS ScreenCaptureKit
    
    和 `quicktime` 同款。分成两档是因为语义不同(一个是 App 录的,一个是系统 API 录的),
    元数据层面当前不做区分。
    
    ### `bare` —— 什么都不写
    
    ```
    handler_name = "(单空格)"
    (无 encoder、无 creation_time)
    ```
    
    **隐私强度最高的一档。** 不留任何可被证伪的声明,也不留时间。
    
    handler 用单空格是有原因的:置空会退回 ffmpeg 的默认值 `VideoHandler`,等于没清。
    见 `residue-map.md` 第 5 条。
    
    ---
    
    ## 选哪一档
    
    | 场景 | 建议 |
    | --- | --- |
    | 发布前清掉自己的隐私信息 | `obs`(默认),够了 |
    | 交付给客户、不想带自己的工具痕迹 | `bare` |
    | 素材库归档,想要一致的元数据 | 任意一档,固定住就行 |
    | 不确定 | `bare`——不写就不会错 |
    
    ---
    
    ## profile 不做的事
    
    - **不写设备型号。** 不会往输出里填 `iPhone 15 Pro` 或任何相机型号。
    - **不写 GPS。** 位置那道门判的是「必须不存在」,不是「伪造一个合理的坐标」。
    - **不写作者、版权、账号。** 这些字段只会被清,不会被填。
    
    profile 只碰三样东西:封装工具的痕迹、handler 名、创建时间。
    
  • skills/video-scrub/references/residue-map.md7.1 KB1b398b0e32a2upstream ↗
    # 五个藏身处
    
    清视频元数据不是一行 `-map_metadata -1` 的事。工具会把身份写进**五个地方**,
    其中三处 `ffprobe` 根本看不见——所以「我清干净了」这个判断本身可能是假的。
    
    以下全部在 ffmpeg 8.1.2 / macOS 上实测,包括几个**看着该管用其实没用**的坑。
    
    ---
    
    ## 1. 容器 tag 的 `encoder`
    
    最显眼的一处,`ffprobe -show_format` 就能看见。
    
    ```
    encoder = Lavf58.45.100
    ```
    
    **堵法:** `-fflags +bitexact`
    
    **注意:** 这个字段由 muxer 自己占着,改不动也清不掉:
    
    | 试过 | 结果 |
    | --- | --- |
    | `-metadata encoder=Lavf60.16.100` | ✗ 盖不过去,输出仍是 ffmpeg 的真版本号 |
    | `-metadata encoder=`(置空) | ✗ 清不掉 |
    | `-fflags +bitexact` | ✓ 整个字段消失 |
    
    **推论:** 想让输出「看起来像某个特定版本的工具产出」是做不到的。
    所以 `obs` 档不伪造版本号——它不加 bitexact,让 ffmpeg 写自己的真版本号。
    
    **另一条实测:** `-fflags +bitexact` 会清掉自动生成的 `creation_time`,
    但**不影响显式写的那个**。`-fflags +bitexact -metadata creation_time=...` 两者可以并存。
    
    ---
    
    ## 2. `avc1` 的 compressorname
    
    藏在 `moov` 的 sample description 里,是 `VisualSampleEntry` 的一个 32 字节 Pascal 串。
    
    ```
    ...\x01\x0cLavc libx264\x00\x00...
    ```
    
    `ffprobe -show_format` 看不见它,`ffprobe -show_entries stream_tags` 能看见一个对应的
    `encoder` 流 tag。
    
    **堵法:** `-metadata:s:v:0 encoder=`
    
    mov muxer 从**流的 `encoder` tag** 取这个字段,置空即清。
    注意和第 1 条的区别:容器级的 `encoder` 置空没用,流级的置空有用。
    
    ---
    
    ## 3. AAC 码流里的 DSE
    
    ffmpeg 的 AAC 编码器把自己的版本号写进 **Data Stream Element**,在音频码流内部。
    
    ```
    Lavc62.28.102
    ```
    
    一条 53 秒的片子里出现 8 处。`ffprobe` 完全看不见。
    
    **堵法:** `-flags:a +bitexact`
    
    **关键推论:** 这是**码流内部**的东西,`-c:a copy` 抹不掉它。
    所以即使走 copy 模式,**音频也必须重编一遍**。代价很小(53 秒的片子约 1 秒),
    换来音轨干净。
    
    ---
    
    ## 4. H.264 的 SEI —— 最刁的一处
    
    x264 把**完整编码参数**写成 SEI 塞在码流里:
    
    ```
    x264 - core 165 r3222 b35605a - H.264/MPEG-4 AVC codec - Copyleft 2003-2025 -
    http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0
    analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16
    ... crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 ...
    ```
    
    这串东西信息量极大——编码器版本、全部参数、CRF 值。**任何 `ffprobe` 命令都看不见它。**
    
    ### 试错记录
    
    | 试过 | 结果 |
    | --- | --- |
    | `-flags:v +bitexact` | ✗ 拦不住,SEI 照写 |
    | `-x264-params info=0` | ✗ 被 ffmpeg 的封装吃掉了,无效 |
    | **`-bsf:v filter_units=remove_types=6`** | ✓ 干净利落 |
    
    **堵法:** `-bsf:v filter_units=remove_types=6`(6 = SEI 的 NAL 类型)
    
    **重要:它在 `-c:v copy` 下照样工作。** 这是 copy 模式能成立的关键——
    不重编画面也能摘掉 SEI。实测抽出前后的 H.264 码流 `cmp`,除了被摘掉的 SEI 之外逐字节一致。
    
    ### 但这把刀太钝 ⚠
    
    ffmpeg 只给得起 **NAL 级**的粒度:
    
    - `filter_units` 只能按 NAL 类型删,删不了单个 SEI payload
    - `h264_metadata` 也没有对应选项(它能 `insert` SEI,不能选择性 `remove`)
    
    所以 `remove_types=6` 是**全部 SEI 一起删**。SEI 里还住着:
    
    - **HDR 静态元数据**——mastering display colour volume / content light level。
      删了 HDR 片子会掉色,tone mapping 直接崩。
    - **CEA-608/708 内嵌字幕**——删了字幕没了。
    - `pic_timing` / `buffering_period`——个别播放器会挑剔。
    
    **所以策略是有条件动刀**(`seiPlan()`):
    
    1. 源片是 HDR → **一律不删**,哪怕有身份串,也只出告警
    2. 码流里没查到身份串 → 不必动刀
    3. 其余情况 → 删
    
    HDR 的判定看 `color_transfer`(`smpte2084` / `arib-std-b67`)、`color_primaries`(`bt2020`)
    和像素格式(`10le` / `12le` / `p010`)。
    
    ---
    
    ## 5. `handler_name`
    
    ```
    VideoHandler / SoundHandler
    ```
    
    **堵法:** 显式写值。
    
    **坑:** `-metadata:s:v:0 handler_name=`(置空)**会退回 ffmpeg 的默认值** `VideoHandler`,
    等于没清。要真空白得写一个**单空格**:
    
    ```
    -metadata:s:v:0 handler_name=" "
    ```
    
    实测:单空格 → 输出的 handler_name 为空,文件里 `VideoHandler` 出现 0 次。
    
    ---
    
    ## 不在这五处、但同样要命的:独立的元数据轨
    
    **GoPro 和 DJI 的 GPS 不在任何 tag 里**,在一条独立的定时元数据轨上
    (GoPro 是 `gpmd` handler,整条 GPMF 遥测流:轨迹、速度、陀螺仪)。
    
    你把 tag 清光了,`ffprobe -show_format` 看着干干净净,**一整条行动轨迹还躺在文件里**。
    
    **堵法:** 白名单选流。
    
    ```
    -map 0:v:0 -map "0:a:0?"
    ```
    
    只显式挑视频和音频,其余一概不带过去——data 轨、timecode 轨、附件、字幕轨全掉。
    配合 `-map_chapters -1` 把章节也挡住。
    
    这就是「流构成」单独占一道门的原因:**不是形式主义,是这类源片唯一的防线。**
    
    ---
    
    ## 完整配方
    
    ```bash
    ffmpeg -v error -y -i <src> \
      -map 0:v:0 -map "0:a:0?" \
      -map_metadata -1 -map_chapters -1 \
      -c:v copy \                                  # 或 -c:v libx264 -crf 18
      -c:a aac -b:a 192k \                         # 音频必须重编,见第 3 条
      -bsf:v "filter_units=remove_types=6" \        # 第 4 条,有条件
      -fflags +bitexact \                           # 第 1 条,bare/quicktime 档
      -flags:a +bitexact \                          # 第 3 条
      -metadata:s:v:0 encoder= \                    # 第 2 条
      -metadata:s:a:0 encoder= \
      -metadata:s:v:0 handler_name="<profile 的值>" \ # 第 5 条
      -metadata:s:a:0 handler_name="<profile 的值>" \
      -movflags +faststart \
      <out>
    ```
    
    ---
    
    ## 字节级扫描的两条讲究
    
    验收时把源片的元数据字符串当「针」在输出里扫,有两个实现细节不能省:
    
    **针要 ≥5 字节。** 更短的串会在压缩数据里随机撞出假阳性——踩过:一次扫描报告
    `Lavc` 和 `x264` 有残留,查偏移才发现是压缩数据里的巧合。跳过的针要在报告里列出来,
    不能默默忽略。
    
    **通用串不当针。** 分界线是**能不能把范围缩小到某个人、某台设备、某次导出**:
    
    | 串 | 当针? | 为什么 |
    | --- | --- | --- |
    | `[email protected]` | ✓ | 指向一个人 |
    | `vid:v1e00fgi0000...` | ✓ | 平台的视频 ID |
    | `iPhone 15 Pro` | ✓ | 指向设备型号 |
    | `Lavf58.45.100` | ✓ | 钉死了一个版本 |
    | `VideoHandler` | ✗ | 满世界都是,信息量为零 |
    | `isom` | ✗ | 结构性 tag,输出里必然还有,当针会自己扎自己 |
    
    **还有一类要豁免:profile 自己写回去的值。** 如果源片也是 ffmpeg 封的、版本号还恰好相同,
    输出的 `encoder` 会和源片一模一样——但它是 muxer 现写的,不是漏过来的。
    这个豁免不开口子:有 `-map_metadata -1` 在,源片的 `encoder` 字段**结构上就到不了**输出。
    
  • skills/video-scrub/README.en.md6.5 KB02dae88aa702upstream ↗
    [![中文](https://img.shields.io/badge/%E4%B8%AD%E6%96%87-ece9e7?style=for-the-badge&labelColor=ece9e7&color=8a8785)](README.md)
    [![English](https://img.shields.io/badge/English-a02128?style=for-the-badge)](README.en.md)
    
    # video-scrub
    
    Rebuilds a video as a clean file: **the picture and the sound come across, not one byte of the
    source's metadata.**
    
    GPS, device model, account IDs, creation time, chapters, a GoPro telemetry track — all left behind.
    
    ## An allowlist, not a blocklist
    
    There are two ways to strip metadata, and the difference matters:
    
    | | How | The problem |
    | --- | --- | --- |
    | Blocklist | Enumerate the fields to delete (what exiftool does) | **You cannot delete what you do not know about** |
    | **Allowlist** | Never say what to delete — say what comes across: one video stream, one audio stream, nothing else | — |
    
    With an allowlist the source's metadata has **no channel** into the output. It is not "deleted";
    it was never carried. The privacy guarantee comes from the structure, not from enumeration.
    
    ## The tags are the easy part
    
    After `-map_metadata -1`, `ffprobe` goes quiet. **Three identity strings are still in the file:**
    
    | Where it hides | What it says | Visible to ffprobe |
    | --- | --- | --- |
    | H.264 **SEI** | `x264 - core 165 ... cabac=1 ref=3 ... crf=23.0` | ✗ |
    | AAC bitstream **DSE** | `Lavc62.28.102` | ✗ |
    | `avc1` **compressorname** | `Lavc libx264` | ✗ |
    
    With the container tag and `handler_name`, that is **five hiding places**, and missing any one of
    them means the file is not clean. Every plug — plus the traps that look like they should work and
    do not (`-flags:v +bitexact` and `-x264-params info=0` both fail to stop the SEI) — is written up
    in [`references/residue-map.md`](references/residue-map.md).
    
    One more that is not in those five and matters just as much: **GoPro and DJI do not put GPS in any
    tag.** It rides on a separate `gpmd` timed-metadata track. Stripping tags does not touch it; only
    "map exactly one video and one audio stream" keeps it out.
    
    ## Lossless by default
    
    ```bash
    node scripts/video-scrub.mjs run <video> -o out.mp4
    ```
    
    | Mode | Picture | Audio | Speed |
    | --- | --- | --- | --- |
    | **`copy`** (default) | **byte-for-byte** | re-encoded | **1.3 s** for a 53 s film |
    | `encode` | re-encoded | re-encoded | much slower |
    
    In copy mode the picture genuinely does not change a single bit — the H.264 bitstreams before and
    after were `cmp`-checked and are identical apart from the SEI that was removed.
    
    Audio is re-encoded in **both** modes: the AAC encoder writes its version into a DSE inside the
    audio bitstream, and `-c:a copy` cannot reach it.
    
    **On watermarks:** what `encode` kills that `copy` does not is bitstream-domain watermarking and
    fragile steganography, both rare in real footage. The ones that actually matter — **robust pixel
    watermarks** such as SynthID or forensic watermarking — are designed to survive re-encoding, and
    **neither mode removes them**. Pick a mode on quality and speed; do not expect a re-encode to wash
    out a watermark.
    
    ## Verification, not assertion
    
    Everything above is "I passed the right flags" — a claim. This step is "I scanned it, it is gone" —
    a proof.
    
    Every metadata string in the source becomes a **needle** — tag keys and values, handler names,
    chapter titles — and the output file is scanned **byte by byte**. One hit turns the gate red.
    
    ```
    demo2.mp4 → clean.mp4  copy / obs
    14 needles scanned
    
      ✓ byte-level residue   ✓ stream layout
      ✓ tag-level residue    ✓ chapters
      ✓ location             ✓ bitstream identity
      ✓ device and software  ✓ profile match
      ✓ source timestamp     ✓ duration
      – rotation matrix      ✓ decodable
    
    ✅ all 12 gates green — not one byte of the source's metadata survived
    ```
    
    A **real run** lives in the repo: [`demo-scrub/`](../../demo-scrub/) — including the most
    instructive counter-example, where the textbook recipe leaves `ffprobe` looking spotless and
    the bitstream-identity gate still goes red.
    
    Two details in picking needles: **≥5 bytes** (shorter strings collide at random inside compressed
    data), and **generic strings are not needles** (`VideoHandler` is in every such file; `Lavf58.45.100`
    pins one version, so it is a fingerprint).
    
    ## Four profiles
    
    The layer written back after the file is wiped. Switch with `--profile <name>`:
    
    | profile | What it writes |
    | --- | --- |
    | **`obs`** (default) | The look of an OBS Studio recording. OBS muxes with ffmpeg itself, so this is not a forgery |
    | `quicktime` | macOS QuickTime screen recording: `Core Media Video` / `Core Media Audio` |
    | `screencapture` | ScreenCaptureKit recording |
    | `bare` | Writes nothing. **The strongest for privacy** — no claim that could be falsified |
    
    A profile touches three things only: the muxing tool's trace, handler names, and creation time.
    **It never writes a device model, never writes GPS, never writes an author or account.**
    See [`references/profiles.md`](references/profiles.md).
    
    ## Commands
    
    ```bash
    inspect <video>                    # what the source carries, including the invisible layers
    scrub   <video> -o out.mp4         # clean it
    verify  <src> <out>                # scan for residue, print the 12 gates
    run     <video> -o out.mp4         # scrub + verify in one go — use this
    ```
    
    Common flags:
    
    ```bash
    --mode encode                  # full re-encode
    --profile bare                 # write nothing
    --crf 18                       # only meaningful in encode mode
    --date 2026-01-01T00:00:00Z    # set the creation time
    --json                         # JSON out of inspect / verify
    ```
    
    ## HDR and embedded captions: when the SEI knife stays in the drawer
    
    ffmpeg only offers NAL-level granularity, so `remove_types=6` removes **every** SEI. Besides the
    x264 junk, SEI also holds **HDR static metadata** (removing it wrecks the colour) and
    **CEA-608/708 embedded captions** (removing it loses the subtitles).
    
    So the knife comes out conditionally: **only when an identity string is actually found, and never
    on an HDR source** — which is reported explicitly, with the reason.
    
    ## Boundaries (what it does not do)
    
    Does not remove watermarks, does not alter the picture (no cropping, scaling or rotating), does not
    fabricate device models or GPS, does not batch-scan directories, does not handle containers other
    than mp4/mov.
    
    ## Requirements and self-test
    
    Just `node` >= 18 and `ffmpeg` / `ffprobe`. No npm dependencies, no API keys.
    
    ```bash
    node scripts/selftest.mjs
    ```
    
    117 assertions, touching neither ffmpeg nor a real file. **Every one of the 12 gates has a breach
    case** — proof that it actually stops things.
    

Plain-text copy, no login: /skill-bundles/eternityspring-reelbench-skills-skills-video-scrub.md

// REPO STATS

1.2k stars
0 open issues
Last commit: 6d ago