fix(mux): -disposition 只对 MP4 写;hev1 源原地降级为 copy 重封装

顾问 Q-16 / Q-17(轮次 3 裁定):

- tracks.py::ffmpeg_args 的 -disposition 回写整块包进 container=="mp4"。
  不传时 matroska muxer 会从输入流继承整条 disposition 掩码(original/comment/
  hearing_impaired…),而 plan() 只提取 default/forced —— 显式传就是用单一标志
  覆盖整条掩码,抹掉 MKV 保真标记
- library_run.py::encode 在 tier_for_bpp 之后加一个分支:mp4 + hevc + tag!=hvc1 +
  yuv420p + 时间轴健康 → 直接 tier="copy"。走 -c:v copy -tag:v hvc1 无损重封装
  (copy 档本就跳过 SSIM),不再为一颗标签重编整片
This commit is contained in:
hoelee committed 2026-10-30 02:00:34 +08:00
1 parent 8b3d979eb3
commit 94350f18b3
2 files changed
+22 -5

No files matched your search

+11
View File
@@ -1424,6 +1424,17 @@ def process(src, args, dest=None, origin=None):
return "SKIP force-tier re-encode refused: already HEVC hvc1 (use --overwrite)", None
log(" force-tier %s (bpp rule said %s)" % (forced, tier))
tier = forced
elif (container == "mp4" and (info.get("vcodec") or "") == "hevc"
and (info.get("tag") or "") != "hvc1" and info.get("pix") in ("yuv420p",)
and not T.unusable_timeline(info, src)[0]):
# 顾问 Q-17(2026-10-30):这一项唯一不达标的地方就是 codec_tag 是 `hev1` ——
# 那是旧版 copy 档漏写 `-tag:v hvc1` 留下的产物(实测量级:io 车道历史只跑过 3 个文件,
# 不值得为它在队列层新增一动作类型)。为改一个标签重编整片是拿几十分钟换五秒钟的活:
# 降到 copy 档就走 `-c:v copy -tag:v hvc1`,无损重封装后原子替换,SSIM 门禁也不需要
# (画面位等同),结构回读 + 全景解码仍然照跑。
log(" codec_tag is %r, everything else is fine -> in-place remux to hvc1 (no re-encode)"
% (info.get("tag") or ""))
tier = "copy"
elif args.tier and args.tier != tier:
return "SKIP classified %s (run wants %s)" % (tier, args.tier), None
expect_vc = "hevc" if tier != "copy" else (info["vcodec"] or "h264")
+11 -5
View File
@@ -308,11 +308,17 @@ def ffmpeg_args(plan_):
# 显式回写(没有标记的就写 `0`,否则 muxer 会自己挑一条标成 default)。
# NB verify() 只做宽松断言,不因 disposition 差异判 FAIL —— 不同 FFmpeg 版本的 MP4
# muxer 对默认轨/forced 的处理并不一致,拿它当硬门禁会造出永远修不好的失败。
for n, a in enumerate(p["audio"]):
args += ["-disposition:a:%d" % n, "default" if a.get("default") else "0"]
for n, s in enumerate(p["subtitles"]):
disp = [w for w, on in (("default", s.get("default")), ("forced", s.get("forced"))) if on]
args += ["-disposition:s:%d" % n, "+".join(disp) if disp else "0"]
# 顾问 Q-16(2026-10-30):**只对 MP4 写** disposition。
# 不传 `-disposition` 时 Matroska muxer 会从输入流完整继承整条 disposition 位掩码
# (original / comment / hearing_impaired …),而这里只提取了 default / forced 两个布尔值 ——
# 一旦对 MKV 显式传 `-disposition:a:n default|0`,就会**用单一标志覆盖整条掩码**,
# 把源片自带的保障性标记抹掉,违背 MKV 保真模式"位等同继承"的承诺。
if p["container"] == "mp4":
for n, a in enumerate(p["audio"]):
args += ["-disposition:a:%d" % n, "default" if a.get("default") else "0"]
for n, s in enumerate(p["subtitles"]):
disp = [w for w, on in (("default", s.get("default")), ("forced", s.get("forced"))) if on]
args += ["-disposition:s:%d" % n, "+".join(disp) if disp else "0"]
return args