"""47 exact saved positions for the SeedVR2 video graph; editorial only.""" from __future__ import annotations import copy import hashlib import importlib.util import json from pathlib import Path REPO = Path(__file__).resolve().parents[3] OUT = Path(__file__).resolve().parent REF = OUT.parent / "seedvr2-video-reference" PATHS = [ ( "example_ComfyUI_workflows/0-基础处理" ":图像合并-音频分离-视频截取合并-图像视频放大/高清放大/Se" "edvr2_3b_int8_视频放大.json" ) ] def canonical(v): return json.dumps(v, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode() def build(index=0): spec = importlib.util.spec_from_file_location( "image_reference_builder", OUT.parent / ("seedvr2-document-evidence/build_definition.py") ) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) image = module.build() raw = (REPO / PATHS[index]).read_bytes() graph = json.loads(raw) sub = graph["definitions"]["subgraphs"][0] entries = json.loads((REF / "sources.json").read_bytes())["sources"] refs = copy.deepcopy(image["sources"]) def ref(file, first, last, claim): e = next(e for e in entries if e["file"] == file) refs.append( { **e, "local_file": "../seedvr2-video-reference/" + e["local_file"], "lines": [first, last], "claim": claim, } ) return len(refs) - 1 load = ref( "comfy_extras/nodes_video.py", 193, 231, "准确core0.28.1 LoadVideo动态视频枚举、video上传、路径验证与VideoFromFile;未读取素材", ) save = ref( "comfy_extras/nodes_video.py", 78, 130, ( "准确SaveVideo是平面format/codec Combo" "及VIDEO返回;不含format.codec或动态嵌套sche" "ma,保存/UI描述符与产物分开" ), ) create = ref( "comfy_extras/nodes_video.py", 133, 173, ( "准确CreateVideo只有images/fps/audio/" "bit_depth,bit_depth是INT而非源COMBO," "无color_space/codec" ), ) components = ref( "comfy_extras/nodes_video.py", 175, 191, "准确GetVideoComponents四出口,bit_depth为INT,不含源图额外color_space出口", ) trim = ref( "comfy_extras/nodes_video.py", 233, 277, "准确Video Slice默认/单位/范围及as_trimmed失败抛错;非保证获得10秒", ) switch = ref( "comfy_extras/nodes_logic.py", 86, 115, "准确ComfySwitchNode布尔真选on_true、假选on_false;lazy请求只选分支", ) ref("comfy_extras/nodes_video.py", 280, 293, "准确视频扩展注册入口") ref("comfy_extras/nodes_logic.py", 334, 353, "准确逻辑扩展注册入口") ref( "comfy_api/latest/_io.py", 248, 267, "Boolean schema默认None;节点未显式default时不称true默认", ) ref( "comfy_api/latest/_io.py", 350, 407, "Combo输入类型/枚举schema;不能将普通Combo改称动态分支" ) enums = ref( "comfy_api/latest/_util/video_types.py", 7, 50, ( "准确VideoCodec auto/h264、Container" " auto/mp4与auto扩展mp4;VideoCompone" "nts含Fraction/audio,可选字段非源实况" ), ) filetrim = ref( "comfy_api/latest/_input_impl/video_types.py", 84, 127, "VideoFromFile负起点从末尾归一、duration取可用时长最小值;非实际片长", ) ref( "comfy_api/latest/_input_impl/video_types.py", 488, 498, "VideoFromFile.as_trimmed仅严格且不足时返回None,其余构造裁剪引用;不执行解码", ) encoding = ref( "comfy_api/latest/_input_impl/video_types.py", 501, 604, ( "准确VideoFromComponents保存仅MP4/H264" "、8/10位、帧率取千分精度、有音频则AAC并按图像长度截取;非" "同步保证;as_trimmed另有不足拒绝" ), ) ref( "comfy_api/latest/_input/video_types.py", 71, 106, "VideoInput基类时间窗口/默认位深/时长接口;具体子类分开", ) ref( "comfy_api/latest/_ui.py", 27, 43, "SavedResult filename/subfolder/type描述符,无产物存在保证", ) ref("comfy_api/latest/_ui.py", 428, 433, "PreviewVideo序列化images和animated元组,非已输出证明") ref( "LICENSE", 1, len((REF / "video__LICENSE").read_text().splitlines()), "准确core0.28.1许可原文", ) ref( "comfy_api/latest/_io.py", 661, 667, "准确Video类型VIDEO标记及VideoInput类型绑定,非源扩展口兼容保证", ) # All implementation/type/enum/UI text cited at precise relevant spans below. dynamic = next(i for i, e in enumerate(refs) if e["file"].endswith("dynamicWidgets.ts")) templates = {f["field"]: f for f in image["fields"]} specials = { "file": ( "输入视频文件引用", "动态input视频枚举,无固定文件默认", "文件引用", "按video内容类型过滤;实际素材未知", ( "保存ComfyUI_00002.mp4,经根边72进入6" "6.video;只是源文件引用,不读取素材、不保证存在或" "可解码。" ), [load], ), "upload": ( "上传控件保存状态", "前端注入;无独立后端参数默认", "前端状态", "保存image字符串;准确schema upload=video", ( "源保存image占位而准确LoadVideo声明vide" "o上传;不当作第二个视频参数、已上传状态或素材路径。" ), [load], ), "filename_prefix": ( "视频保存文件名前缀", "video/ComfyUI", "文本", "准确实现用output目录及计数命名", ( "保存video/Upscaled_seedVR2,条件调用vid" "eo.save_to并返回VIDEO和UI文件描述符;未保存任何" "视频,准确枚举auto/mp4的扩展规则为mp4,VideoFr" "omComponents条件仅MP4/H264,有音频则AAC;" "这不是实际扩展名/编码器/元数据结果。" ), [save], ), "format": ( "保存容器选择", "auto", "枚举", "准确0.28.1为平面Combo,选项见固定VideoContainer", ( "源口声明动态类型而准确schema是普通Combo。保存" "auto仅请求自动容器,不保证实际格式;不把format" ".codec并入该值。" ), [save], ), "format.codec": ( "源保存的嵌套编码选择", "未知:准确schema无此项", "源动态分支保存文本", "准确SaveVideo无format.codec字段", ( "原位置独立保存auto;准确0.28.1仅平面forma" "t和codec,源额外动态层次无法按此版本确认,不合并、" "不删值、不补分支。" ), [save, dynamic], ), "fps": ( "视频重组帧率缓存", "30.0", "帧/秒", "1.0~120.0,step1.0", ( "内部75保存JSON int30,外线69由74.fps" "覆盖;拆分端准确float(frame_rate),不能" "用缓存保证实际30FPS或音画同步。" ), [create, components], ), "bit_depth": ( "视频重组位深缓存", "8", "位", "INT 8~10,step2;源输入COMBO与准确INT不一致", ( "保存JSON int8,外线70由74.bit_depth覆盖;" "边记录type INT而源两端口COMBO。准确0.28.1两端" "均INT,保留差异,不据缓存证明实际8位。" ), [create, components], ), "color_space": ( "源保存的重组色彩空间", "未知:准确schema无此项", "源枚举标签", "准确CreateVideo没有color_space输入,GetVideoComponents也无该出口", "保存sRGB且未接线;准确0.28.1无该字段,不等于已应用sRGB,不推断色彩管理或保真。", [create, components], ), "switch": ( "是否选择修剪视频", "未显式指定;Boolean默认None", "布尔值", "true选择on_true,false选择on_false;lazy只请求所选分支", ( "宿主66保存true经边80覆盖内部81缓存true;81.on" "_true经77来自79切片,on_false经78来自原vid" "eo。准确实现真选切片,不凭类名推测、不执行开关。" ), [switch], ), "start_time": ( "修剪起点", "0.0", "秒", "-100000~100000,step0.001;负值实际解释见视频类型实现", ( "宿主保存JSON int0,经边81覆盖内部79缓存0;" "由准确as_trimmed处理。未读取素材,起点有效性未" "知。" ), [trim], ), "duration": ( "修剪目标时长", "0.0", "秒", "最小0、step0.001;0表示不限时长;未声明max", ( "宿主保存JSON int10经边82覆盖内部79缓存10;str" "ict_duration=false并不保证输出10秒,短片/负" "起点等条件另见准确视频实现。" ), [trim], ), "strict_duration": ( "严格要求修剪时长", "False", "布尔值", "true请求严格时长;false仍可能失败", ( "内部79独立保存false,无宿主覆盖。准确节点调用as" "_trimmed,返回None即抛ValueError;" "不把false当无条件成功。" ), [trim], ), } effects = { "seed": ( "宿主seed_1保存959948902156062,经边87覆盖" "内部54.seed缓存;内部fixed另为生成后前端控制,不求随" "机值或补宿主控制。" ), "control_after_generate": ( "仅内部54保存fixed;宿主没有独立保存该控制,和seed_1分开。不构造随机值或prompt。" ), "steps": "仅内部54保存1,没有宿主steps边界或覆盖;单步不是实际画质、速度或成功保证。", "cfg": ( "仅内部54保存JSON int1,对应FLOAT sch" "ema,没有宿主cfg边界;条件来自61,模型适配和效果" "未知。" ), "sampler_name": ( "保存euler,宿主边90覆盖内部54缓存;准确采样器枚举包含euler,不证明SeedVR2适配。" ), "scheduler": "保存simple,宿主边91覆盖内部54缓存;准确调度器枚举包含simple,不是实跑证明。", "denoise": "保存JSON int1,宿主边92覆盖内部54缓存;1不证明注释所称full restore或保真效果。", "unet_name": ( "宿主及内部52均保存Seedvr2\\seedvr2_3b_int" "8_convrot.safetensors(大小写逐字保留),宿" "主边94覆盖内部缓存;Note推荐路径另列,不验证磁盘/模型/精" "度。" ), "vae_name": ( "宿主seedvr2_ema_vae_fp16.safetenso" "rs经边95覆盖内部51缓存ema_vae_fp16.safet" "ensors;与Note推荐并列,不替换、不证明安装。" ), "resize_type.multiplier": ( "保存JSON int2;宿主resize_type.multip" "lier_1经边86覆盖内部57缓存。准确resize按roun" "d计算宽高再插值;倍率插值与模型效果分开,实际尺寸未知。" ), "color_correction_method": ( "宿主none经边93覆盖内部59缓存none;三类SeedVR2" "准确实现仍未证,不能保证无颜色变化或可用选项。" ), "temporal_size": ( "内部48编码与55解码分别保存4096;本图无宿主tempora" "l_size输入或外线。仅视频VAE使用时间窗口,不保证帧数、内" "存或成功。" ), "tile_size": ( "内部48编码与55解码分别保存512;无宿主覆盖。准确实" "现按VAE压缩换算,分块不保证显存足够或无接缝。" ), "overlap": ( "内部48编码与55解码分别保存128;无宿主覆盖。准确解" "码按tile_size限幅和压缩换算,保留源值,不保证无" "接缝。" ), "temporal_overlap": ( "内部48/55分别保存8;仅视频VAE时间分块适用,按压缩换算/限幅,不保证同步或资源容量。" ), "weight_dtype": ( "内部52独立保存default,无宿主覆盖;文件名int" "8不证明实际加载/计算dtype、设备支持或速度。" ), "resize_type": "内部57保存scale by multiplier;只列此动态分支,不补宽高或其它未保存分支。", "scale_method": ( "内部57保存lanczos;准确schema默认area" "另列。只是倍率插值算法,不是SeedVR2超分模型或清晰" "度保证。" ), } fields = [] missing = [] comments = [] for scope, g, prefix in [ ("root", graph, ""), ("subgraph:" + sub["id"], sub, "/definitions/subgraphs/0"), ]: for i, n in enumerate(g["nodes"]): base = f"{prefix}/nodes/{i}" if "widgets_values" not in n: missing.append( dict( node_id=str(n["id"]), class_type=n["type"], pointer=base, value_state="missing", effect=( "源未保存widgets_values,非[]或null,零保存位" "置,不补值;SeedVR2准确实现/素材内容仍未知。" ), ) ) continue if n["type"] == "MarkdownNote": assert n["widgets_values"][0] == n["widgets_values_named"]["text"] comments.append( dict( node_id=str(n["id"]), pointer=base + "/widgets_values/0", named_pointer=base + "/widgets_values_named/text", text=n["widgets_values"][0], meaning=( "注释78:子图指南、VAE/UNET模型引用及SEEDVR2与diffusion_models目录建议," "另列更新及后端/前端/模板报错入口。推荐VAE名与宿主保存名不同;" "目录不是已安装证明,链接仅原文,不更新软件、下载或执行。" if n["id"] == 78 else "注释82:自述3B Int8单步视频恢复,列项目及原生支持PR链接;" "trim_video/trim_start_time/scale_multiplier只是Note用语," "实际源保存名为switch/start_time/resize_type.multiplier_1,不生成别名参数。" "Note称倍率默认2、颜色默认none及denoise=1 full restore;" "这些是原文陈述,准确schema默认及未知项分别见逐位置说明。" "短段处理再合并是建议,本图无合并节点,未证明防OOM、耗时或画质;链接不执行。" ), ) ) continue names = list(n["widgets_values_named"]) assert len(names) == len(n["widgets_values"]) for k, (name, value) in enumerate(zip(names, n["widgets_values"])): assert canonical(value) == canonical(n["widgets_values_named"][name]) normalized = { "seed_1": "seed", "resize_type.multiplier_1": "resize_type.multiplier", }.get(name, name) if normalized == "codec": if n["id"] == 76: data = ( "保存编码器选择", "auto", "枚举", "准确0.28.1平面codec Combo;与format.codec位置分开", ( "根76独立codec保存auto;准确schema支持此平面字段" "但不支持额外嵌套项,不归并多个auto,也不保证实际编解码器可用" "。" ), [save], ) else: data = ( "源保存的重组编码标签", "未知:准确schema无此项", "源枚举标签", "准确CreateVideo没有codec参数", ( "内部75保存none且未接线;准确0.28.1无此字段," "不解释为已无损/未编码/禁用编码。" ), [create], ) else: data = specials.get(normalized) if data: label, default, unit, limits, effect, ev = data f = dict( label=label, schema_default=default, unit=unit, limits=limits, effect=effect, evidence=ev, ) else: f = copy.deepcopy(templates[normalized]) f["effect"] = effects[normalized] inp_idx = next( (j for j, p in enumerate(n.get("inputs", [])) if p["name"] == name), None ) named = base + "/widgets_values_named/" + name.replace("~", "~0").replace("/", "~1") inp = f"{base}/inputs/{inp_idx}" if inp_idx is not None else named linked = inp_idx is not None and n["inputs"][inp_idx].get("link") is not None role = ( "linked_saved" if linked else "frontend_control" if normalized in ["upload", "control_after_generate"] else "scalar" ) f.update( node_id=str(n["id"]), scope=scope, class_type=n["type"], field=name, pointer=f"{base}/widgets_values/{k}", named_pointer=named, input_pointer=inp, value=value, json_type=type(value).__name__, type=next( (p["type"] for p in n.get("inputs", []) if p["name"] == name), "前端状态" ), role=role, execution_note="仅原保存态,mode0非实跑;具名双指针:" + named + ";源口/前端状态:" + inp, ) f["evidence"] = list( dict.fromkeys( f["evidence"] + [19, 20, 21, 22] + ( [enums, encoding] if n["id"] in [75, 76] else [filetrim] if normalized in ["start_time", "duration", "strict_duration"] else [] ) + ([23] if normalized == "upload" else []) ) ) # exact host/subgraph/callback source references fields.append(f) assert len(fields) == 47 and len(comments) == 2 boundaries = [] ns = {n["id"]: n for n in sub["nodes"]} for j, port in enumerate(sub["inputs"]): edges = [e for e in sub["links"] if e["origin_id"] == -10 and e["origin_slot"] == j] assert {e["id"] for e in edges} == set(port["linkIds"]) for e in edges: target = ns[e["target_id"]] ti = sub["nodes"].index(target) assert target["inputs"][e["target_slot"]]["link"] == e["id"] boundaries.append( dict( host_slot=j, name=port["name"], host_pointer=f"/nodes/4/inputs/{j}", definition_pointer=f"/definitions/subgraphs/0/inputs/{j}", edge=e, target_pointer=f"/definitions/subgraphs/0/nodes/{ti}/inputs/{e['target_slot']}", ) ) overview = ( "这张图读取视频,按已保存的开关选择原片或修剪片段,再把画面放大、" "经过SeedVR2链处理,与音频和帧率重组后保存。当前开关为真," "修剪请求从0秒起10秒,倍率2;都只是保存设置,不能保证实际时长" "、画质或显存足够。视频节点的源保存项与准确版本有不匹配,还有一条" "悬空历史端点;仅供参考,保持转换关闭、未实跑。" ) flow = [ overview, ( "根5节点/2边、内部13节点/34含边界记录,全mode0。73" ".LoadVideo经72→66.video;66.VIDEO经" "73→76.SaveVideo。同UUID1970dcb4…不等" "于上一图片图同一定义。" ), ( "宿主video分别经74→79.Video Slice.vide" "o、78→81.on_false;79切片经77→81.on_t" "rue。准确core0.28.1 switch=true选择on" "_true且lazy只请求该支;false选择原片。宿主true" "经80覆盖81保存true;0/10经81/82覆盖79缓存;s" "trict_duration=false独立。未执行切片,不保证" "10秒或规避OOM。" ), ( "异常:79输出links原保存[76,77],定义links清单" "没有id76;只记录悬空/历史端点,不删线、不模拟修复、不把它计" "入34条真实记录。定义输出71由75→-20,不能把悬空76猜成" "输出。" ), ( "81经79→74.GetVideoComponents;74.i" "mages经66→57.Resize→58.Preprocess" "→48.Encode;48→61.Conditioning及54" ".KSampler,52.UNET→61及54,61正负→54," "54→55.Decode→59.PostProcessing→7" "5.images。51.VAE→48/55,57另→59.ori" "ginal_resized_images。三类SeedVR2实现" "仅沿用core0.27.0有界未证结论,不借新版或同名插件。" ), ( "准确VideoFromFile负起点从片尾归一、时长取可用最小值" ",strict=false不保证片长;VideoFromComp" "onents另一实现不足时返回None,不混同。74.audio" "/fps/bit_depth分别经68/69/70→75;fps" "缓存JSON int30、bit_depth缓存JSON int" "8均被外线覆盖。源bit_depth两端口COMBO而边type" " INT;准确0.28.1两端INT。74源还保存color_s" "pace出口但未接,准确版本仅四出口;75源保存sRGB/non" "e未接而准确schema无color_space/codec。准" "确重组保存按千分精度取帧率、8/10位选择YUV格式、音频按帧数" "截取并条件AAC;这些静态条件不能保证实际音轨、FPS、色彩或同" "步。" ), ( "根76保存四位置[video/Upscaled_seedVR2," "auto,auto,auto];format、format.co" "dec、codec独立保留。准确0.28.1 SaveVideo" "只有平面format和codec普通Combo,无嵌套forma" "t.codec,源动态口不匹配;不归并、不补控件、不凭保存顺序构" "造prompt。准确VIDEO返回及UI文件描述符不证明已产出。" ), ( "12宿主输入=video+11控件,video分叉形成13条输入" "边界记录;不是13个输入。边86倍率→57;87seed_1→5" "4;90/91/92算法/调度/denoise→54;93non" "e→59;94/95模型→52/51;无steps/cfg/te" "mporal宿主边。内部steps1/cfg1/fixed与51" "2/128/4096/8分别保存,不当外线值。" ), ( "倍率2/lanczos是插值条件,不保证模型效果;宿主/内部UN" "ET均Seedvr2\\seedvr2_3b_int8_convr" "ot.safetensors,逐字保持。VAE宿主seedvr2" "_ema_vae_fp16与内部ema_vae_fp16不同;两" "Note模型推荐/目录/项目/PR链接只原文,不执行下载或替换。" "one-step/full restore/防OOM建议非实测。" ), ( "源声明视频/切片/开关core0.28.1,其余模型/采样/re" "size/core宿主0.27.0,frontend1.45.2" "0分别绑定。准确核心文本/schema/注册/视频实现/许可静态" "核对,不安装执行上游/GPU/媒体/随机种子。三SeedVR2类" "默认/范围/效果/真实提供方未知。" ), ( "全节点UE7.8与宿主可连接表、previewExposures" "指54只是保存属性;恢复次序未知分层。准确frontend先属性" "/保存值再onConfigure,子图重建槽后恢复代理,不能推U" "E最终值。根extra缺links_added_by_ue键,内" "部extra只有ue_links空;缺键不补[]。58/61/7" "4缺widgets_values,非空[]或null。" ), ( "47保存位置=根17+内部30,均标量;另2完整Markdown" "Note。旧31块941位置+22注释逐对象冻结,现32图988" "位置+24注释仅参考。155完整定稿0/必要实跑0/新增转换0;" "145UI仍9参考候选136关闭。" ), ] flow.extend("注释中文说明:" + note["meaning"] for note in comments) for scope, g in [("root", graph), ("subgraph:" + sub["id"], sub)]: flow.extend("原边 " + scope + " " + json.dumps(e, ensure_ascii=False) for e in g["links"]) flow.extend("边界 " + json.dumps(e, ensure_ascii=False) for e in boundaries) # Compact exact inherited references to those actually relevant; no image comparer attribution. inherited = [ i for i, e in enumerate(refs[: len(image["sources"])]) if e["id"] != "rgthree" and i not in [0, 1, 2, 15, 23] ] used = sorted( set( inherited + list(range(len(image["sources"]), len(refs))) + [i for f in fields for i in f["evidence"]] ) ) remap = {old: new for new, old in enumerate(used)} for f in fields: f["evidence"] = [remap[i] for i in f["evidence"]] sources = [refs[i] for i in used] versions = [ "core0.27.0→" + next(e["commit"] for e in sources if e["id"] == "core"), "core0.28.1→" + entries[0]["commit"], "frontend1.45.20→" + next(e["commit"] for e in sources if e["id"] == "frontend"), ] return dict( source_path=PATHS[index], source_sha1=hashlib.sha1(raw).hexdigest(), source_sha256=hashlib.sha256(raw).hexdigest(), canonical_sha256=hashlib.sha256(canonical(graph)).hexdigest(), notice=( "仅准确来源参考;视频schema差异、悬空端点、Seed" "VR2实现、模型素材及扩展恢复未知;转换关闭、未实跑。" ), user_overview=overview, versions=versions, counts=dict( saved_fields=47, source_nodes=18, physical_edges=36, source_notes=2, history_objects=0, linked_saved_fields=sum(f["role"] == "linked_saved" for f in fields), frontend_only=2, final_scalars=0, final_prompt_constructed=False, ), fields=fields, sources=sources, comments=comments, flow=flow, flow_evidence=list(range(len(sources))), zero_saved_nodes=missing, boundaries=boundaries, steps=[ overview, "操作1:分别核对原片/切片两支、悬空76与宿主边界,保持停用;不上传或处理素材。", ( "操作2:逐位置核对模型路径、固定种子、内部缓存与覆盖;准" "确版本差异未确认前不构造prompt。" ), "操作3:实际音轨/FPS/同步/编解码器/设备/画质未知;后续全量审查通过前不作为生成入口。", ], )