538 lines
22 KiB
Python
538 lines
22 KiB
Python
"Source-bound RTX video reference; only read static text, never upstream code/media."
|
||
|
||
from __future__ import annotations
|
||
|
||
import hashlib
|
||
import json
|
||
from pathlib import Path
|
||
|
||
REPO = Path(__file__).resolve().parents[3]
|
||
OUT = Path(__file__).resolve().parent
|
||
REF = OUT.parent / "rtx-video-reference"
|
||
PATHS = [
|
||
(
|
||
"example_ComfyUI_workflows/0-基础处理:图像合并-"
|
||
"音频分离-视频截取合并-图像视频放大/高清放大/RTX_video_upsc"
|
||
"ale.json"
|
||
)
|
||
]
|
||
|
||
|
||
def canonical(value):
|
||
return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode()
|
||
|
||
|
||
def build(index=0):
|
||
path = PATHS[index]
|
||
raw = (REPO / path).read_bytes()
|
||
graph = json.loads(raw)
|
||
entries = json.loads((REF / "sources.json").read_bytes())["sources"]
|
||
refs = []
|
||
|
||
def ref(key, file, first, last, claim):
|
||
e = next(e for e in entries if e["id"] == key and e["file"] == file)
|
||
data = (REF / e["local_file"]).read_bytes()
|
||
assert hashlib.sha256(data).hexdigest() == e["sha256"]
|
||
assert 1 <= first <= last <= len(data.decode().splitlines())
|
||
refs.append(
|
||
{
|
||
**e,
|
||
"local_file": "../rtx-video-reference/" + e["local_file"],
|
||
"lines": [first, last],
|
||
"claim": claim,
|
||
}
|
||
)
|
||
return len(refs) - 1
|
||
|
||
schema = ref(
|
||
"rtx",
|
||
"__init__.py",
|
||
10,
|
||
49,
|
||
"准确Registry0.1.0动态尺寸schema、倍率默认/范围和质量枚举;Git绑定未知",
|
||
)
|
||
run = ref(
|
||
"rtx",
|
||
"__init__.py",
|
||
51,
|
||
109,
|
||
"准确包尺寸取整、8倍数对齐、按面积分批及CUDA/nvvfx调用;不执行",
|
||
)
|
||
ref("rtx", "__init__.py", 112, 121, "准确包节点注册入口")
|
||
pkg = ref(
|
||
"rtx", "pyproject.toml", 1, 16, "准确包0.1.0版本与nvidia-vfx依赖;未固定运行库或Git绑定"
|
||
)
|
||
dynamic = ref(
|
||
"core", "comfy_api/latest/_io.py", 1090, 1142, "准确核心DynamicCombo选择分支schema"
|
||
)
|
||
ref("core", "comfy_api/latest/_io.py", 654, 658, "准确核心VIDEO IO类型;Type引用VideoInput别名")
|
||
front = ref(
|
||
"frontend",
|
||
"src/core/graph/widgets/dynamicWidgets.ts",
|
||
72,
|
||
206,
|
||
"准确前端动态子控件插入/移除和恢复回调;不证明UE次序",
|
||
)
|
||
save = ref(
|
||
"core",
|
||
"comfy_extras/nodes_video.py",
|
||
68,
|
||
114,
|
||
"SaveVideo schema、元数据条件、output命名与保存描述符",
|
||
)
|
||
create = ref(
|
||
"core",
|
||
"comfy_extras/nodes_video.py",
|
||
117,
|
||
140,
|
||
"CreateVideo fps默认30.0/1~120/step1,Fraction包装及可选音频",
|
||
)
|
||
split = ref(
|
||
"core",
|
||
"comfy_extras/nodes_video.py",
|
||
142,
|
||
164,
|
||
"GetVideoComponents依次返回images/audio/float(frame_rate)",
|
||
)
|
||
load = ref(
|
||
"core",
|
||
"comfy_extras/nodes_video.py",
|
||
167,
|
||
205,
|
||
"LoadVideo动态视频列表、上传类型及VideoFromFile构造/文件检查",
|
||
)
|
||
ref("core", "comfy_extras/nodes_video.py", 259, 272, "准确核心视频节点注册和入口")
|
||
paths = ref(
|
||
"core", "folder_paths.py", 428, 472, "output子目录、计数命名及路径边界规则;不访问目录"
|
||
)
|
||
upload = ref(
|
||
"frontend",
|
||
"src/extensions/core/uploadImage.ts",
|
||
1,
|
||
53,
|
||
"准确前端video_upload媒体COMBO附加IMAGEUPLOAD占位输入",
|
||
)
|
||
restore = ref(
|
||
"frontend",
|
||
"src/lib/litegraph/src/LGraphNode.ts",
|
||
865,
|
||
909,
|
||
"宿主先恢复属性与可序列化widgets_values,再调用onConfigure;不证明扩展最终值",
|
||
)
|
||
callbacks = ref(
|
||
"frontend",
|
||
"src/scripts/app.ts",
|
||
747,
|
||
772,
|
||
(
|
||
"宿主图级fixLinkInputSlots、onGraphConfigure"
|
||
"d、原onConfigure及onAfterGraphConfigured次"
|
||
"序;UE未知"
|
||
),
|
||
)
|
||
types = ref(
|
||
"core",
|
||
"comfy_api/latest/_util/video_types.py",
|
||
1,
|
||
49,
|
||
("VideoCodec auto/h264,VideoContainer auto/mp4及扩展名规则,VideoComponents结构"),
|
||
)
|
||
ref(
|
||
"core",
|
||
"comfy_api/latest/_input/video_types.py",
|
||
1,
|
||
128,
|
||
"VideoInput抽象接口及继承默认维度、帧数、时长和帧率取值",
|
||
)
|
||
fileimpl = ref(
|
||
"core",
|
||
"comfy_api/latest/_input_impl/video_types.py",
|
||
55,
|
||
78,
|
||
"VideoFromFile继承VideoInput并保存文件引用;非已解码素材证明",
|
||
)
|
||
decode = ref(
|
||
"core",
|
||
"comfy_api/latest/_input_impl/video_types.py",
|
||
235,
|
||
305,
|
||
"文件视频组件读取:视频帧、average_rate或1回退、可选末音轨;仅静态条件",
|
||
)
|
||
encode = ref(
|
||
"core",
|
||
"comfy_api/latest/_input_impl/video_types.py",
|
||
382,
|
||
458,
|
||
"VideoFromComponents继承、MP4/H264限制、千分率取整、yuv420p及条件AAC/音频截取",
|
||
)
|
||
for f in [
|
||
"comfy_api/input/__init__.py",
|
||
"comfy_api/input/video_types.py",
|
||
"comfy_api/latest/_input/__init__.py",
|
||
"comfy_api/latest/_input_impl/__init__.py",
|
||
]:
|
||
e = next(e for e in entries if e["file"] == f)
|
||
ref(
|
||
"core",
|
||
f,
|
||
1,
|
||
len((REF / e["local_file"]).read_text().splitlines()),
|
||
"准确核心视频输入/实现别名与导出链;不借不同版本",
|
||
)
|
||
ref(
|
||
"core",
|
||
"comfy_api/latest/_input/basic_types.py",
|
||
1,
|
||
24,
|
||
"图像张量/AudioInput后端类型定义;不从文件名判断存在音轨",
|
||
)
|
||
ui = ref(
|
||
"core",
|
||
"comfy_api/latest/_ui.py",
|
||
27,
|
||
55,
|
||
"SavedResult filename/subfolder/type文件描述符,不是媒体字节",
|
||
)
|
||
ref(
|
||
"core",
|
||
"comfy_api/latest/_ui.py",
|
||
428,
|
||
440,
|
||
"PreviewVideo序列化images描述符,不能证明实际保存或媒体格式",
|
||
)
|
||
for key in ["rtx", "core", "frontend"]:
|
||
e = next(e for e in entries if e["id"] == key and e["file"] == "LICENSE")
|
||
ref(
|
||
key,
|
||
"LICENSE",
|
||
1,
|
||
len((REF / e["local_file"]).read_text().splitlines()),
|
||
"准确提交/发布包许可原字节;不推目标许可适用性",
|
||
)
|
||
specs = {
|
||
"GetVideoComponents": [],
|
||
"SaveVideo": [
|
||
(
|
||
"filename_prefix",
|
||
"输出视频文件名前缀",
|
||
"STRING",
|
||
"video/ComfyUI",
|
||
"文本,无数值单位",
|
||
"未声明长度范围;按output子目录和计数规则处理",
|
||
(
|
||
"保存video/ComfyUI;8重组视频经边10送入9。准确核心按outp"
|
||
"ut配置和输入维度计算目录及计数名;不是绝对目录或已保存证明。元数据受dis"
|
||
"able_metadata及prompt/extra_pnginfo条件控制"
|
||
",不保证带原视频元数据。"
|
||
),
|
||
[save, paths, ui],
|
||
"scalar",
|
||
),
|
||
(
|
||
"format",
|
||
"输出容器格式",
|
||
"COMBO",
|
||
"auto",
|
||
"容器枚举",
|
||
"准确核心选项auto / mp4;不推目标编码库支持",
|
||
(
|
||
"保存auto。准确VideoContainer.get_extension对"
|
||
"auto/mp4返回mp4,准确VideoFromComponents仅接受"
|
||
"AUTO/MP4;这是固定版本保存路径规则,不是本次实际扩展名、文件存在或编"
|
||
"码成功证明。"
|
||
),
|
||
[save, types, encode],
|
||
"scalar",
|
||
),
|
||
(
|
||
"codec",
|
||
"视频编码器选择",
|
||
"COMBO",
|
||
"auto",
|
||
"编码枚举",
|
||
"准确核心选项auto / h264;不是任意编码器自动挑选保证",
|
||
(
|
||
"保存auto。准确VideoFromComponents仅允许AUTO/H2"
|
||
"64并调用h264、yuv420p;可选音频为AAC。目标PyAV/编解码器"
|
||
"、驱动和实际输出未知,不把auto当保留输入视频编码或无损复制。"
|
||
),
|
||
[save, types, encode],
|
||
"scalar",
|
||
),
|
||
],
|
||
"CreateVideo": [
|
||
(
|
||
"fps",
|
||
"重组视频帧率的源保存值",
|
||
"FLOAT(schema);原JSON int",
|
||
"30.0",
|
||
"帧/秒(FPS)",
|
||
"schema 1.0~120.0、step1.0;当前fps有边9外线,保存30不作最终输入",
|
||
(
|
||
"原JSON int 30只为缓存;边9从7.fps输出槽2覆盖8.fps输入"
|
||
"槽2,取自输入视频拆分链,不据30保证实际帧率。准确核心经float(fra"
|
||
"me_rate)再Fraction(fps)组装,保存实现再千分率取整。音频"
|
||
"走独立边8,源音轨可能不存在,时长/帧数/音画同步均未知,不把连线当同步保证"
|
||
"。"
|
||
),
|
||
[create, split, decode, encode, restore, callbacks],
|
||
"linked_saved",
|
||
),
|
||
],
|
||
"RTXVideoSuperResolution": [
|
||
(
|
||
"resize_type",
|
||
"画面尺寸处理模式",
|
||
"COMFY_DYNAMICCOMBO_V3",
|
||
"schema未显式给默认;选项顺序scale by multiplier、target dimensions",
|
||
"模式标签",
|
||
"只在所选分支展开子参数;源保存scale by multiplier",
|
||
(
|
||
"源选择倍率分支,才读取resize_type.scale;目标尺寸分支wid"
|
||
"th/height未保存,不补默认1920/1080为当前值。只处理7拆分的"
|
||
"images,不处理音轨或改变帧率的连线。"
|
||
),
|
||
[schema, dynamic, front],
|
||
"scalar",
|
||
),
|
||
(
|
||
"resize_type.scale",
|
||
"倍率分支的缩放因子",
|
||
"FLOAT(schema);原JSON int",
|
||
"2.0",
|
||
"无量纲倍率",
|
||
"schema 1.0~4.0、step0.01;仅scale by multiplier分支有效",
|
||
(
|
||
"本图原JSON int 1,与上一图片图2和schema默认2.0分别保留。"
|
||
"准确实现先int(w*scale)/int(h*scale),再各max(8"
|
||
",round(维度/8)*8)对齐;输入尺寸未知,倍率1也不能保证当前尺寸不"
|
||
"变或清晰度改善。无物理外线覆盖本字段。"
|
||
),
|
||
[schema, run, dynamic, front],
|
||
"scalar",
|
||
),
|
||
(
|
||
"quality",
|
||
"超分质量档位",
|
||
"COMBO",
|
||
"ULTRA",
|
||
"枚举,无数值单位",
|
||
"LOW / MEDIUM / HIGH / ULTRA",
|
||
(
|
||
"保存ULTRA,准确包映射nvvfx质量枚举并调用VideoSuperRes"
|
||
".load/run及CUDA;MAX_PIXELS=1024*1024*16"
|
||
"按输出面积分批,batch_size至少1,不是显存或耗时保证。运行库版本/"
|
||
"目标GPU/驱动及实际画质未知,不执行超分。"
|
||
),
|
||
[schema, run, pkg],
|
||
"scalar",
|
||
),
|
||
],
|
||
"LoadVideo": [
|
||
(
|
||
"file",
|
||
"输入视频文件引用",
|
||
"COMBO",
|
||
"动态input视频枚举,无固定文件默认",
|
||
"文件引用",
|
||
"input目录普通文件经video内容类型筛选并排序;实际列表未知",
|
||
(
|
||
"原样保存WanVideo_00003-audio.mp4。文件名含audio"
|
||
"和.mp4不证明文件存在、实际容器、音轨、时长、帧数或FPS。准确核心构造V"
|
||
"ideoFromFile;6经边5送7拆分,未读取素材或媒体探测。"
|
||
),
|
||
[load, fileimpl, decode],
|
||
"scalar",
|
||
),
|
||
(
|
||
"upload",
|
||
"视频上传控件保存占位",
|
||
"IMAGEUPLOAD(前端)",
|
||
"前端按video_upload注入;非后端第二参数默认",
|
||
"前端状态,无数值单位",
|
||
"原保存字符串image;不是第二段视频、路径或已上传证明",
|
||
(
|
||
"保存image仅上传控件占位,和上一个文件名分开保留。准确LoadVideo"
|
||
"仅具名file参数,前端媒体COMBO扩展补upload;不据占位推视频内容"
|
||
"、可读性或最终恢复结果,不上传素材。"
|
||
),
|
||
[load, upload, restore, callbacks],
|
||
"frontend_control",
|
||
),
|
||
],
|
||
}
|
||
fields = []
|
||
for i, n in enumerate(graph["nodes"]):
|
||
assert len(n["widgets_values"]) == len(specs[n["type"]])
|
||
for k, (name, label, typ, default, unit, limits, effect, ev, role) in enumerate(
|
||
specs[n["type"]]
|
||
):
|
||
v = n["widgets_values"][k]
|
||
input_index = next(j for j, port in enumerate(n["inputs"]) if port["name"] == name)
|
||
input_pointer = f"/nodes/{i}/inputs/{input_index}"
|
||
fields.append(
|
||
dict(
|
||
field=name,
|
||
label=label,
|
||
type=typ,
|
||
schema_default=default,
|
||
unit=unit,
|
||
limits=limits,
|
||
effect=effect,
|
||
evidence=ev,
|
||
role=role,
|
||
node_id=str(n["id"]),
|
||
scope="root",
|
||
class_type=n["type"],
|
||
pointer=f"/nodes/{i}/widgets_values/{k}",
|
||
input_pointer=input_pointer,
|
||
value=v,
|
||
json_type=type(v).__name__,
|
||
execution_note=(
|
||
"原mode=0仅活动保存态;未执行、未构造prompt,声明版本不是目标安装证明。"
|
||
+ "源输入口:"
|
||
+ input_pointer
|
||
),
|
||
)
|
||
)
|
||
assert len(fields) == 9 and all(not isinstance(f["value"], (dict, list)) for f in fields)
|
||
overview = (
|
||
"这张图把视频拆成画面、音频和帧率,只对画面做RTX超分,再接回原音频和FPS"
|
||
"重组并保存。保存倍率为1、质量ULTRA;帧率缓存30被外线覆盖,实际FPS"
|
||
"、音轨、音画同步、尺寸和画质均未核。UE7.7恢复次序及目标GPU/驱动/编"
|
||
"解码器未知;仅固定参考,转换关闭、未实跑。"
|
||
)
|
||
flow = [
|
||
overview,
|
||
(
|
||
"根5节点6物理边,全mode0,无子图/源注释/历史对象。6.LoadVid"
|
||
"eo→7.GetVideoComponents;7.images槽0经边19"
|
||
"→1.RTX.images;1.upscaled_images经边7→8.C"
|
||
"reateVideo.images;7.audio槽1经边8→8.audio"
|
||
";7.fps槽2经边9→8.fps槽2;8.VIDEO经边10→9.Save"
|
||
"Video.video。逐端点核对,不模拟执行。"
|
||
),
|
||
(
|
||
"7.widgets_values=[]为零保存位置,不制造控件或历史对象。8"
|
||
"保存30为JSON int,准确schema默认30.0/1~120/ste"
|
||
"p1和fps外线三层分开;7准确实现float(components.fra"
|
||
"me_rate),8经Fraction(fps)构造VideoFromCom"
|
||
"ponents。实际文件FPS和输出同步未知。"
|
||
),
|
||
(
|
||
"RTX准确Registry0.1.0保存scale by multiplie"
|
||
"r、JSON int 1、ULTRA。先乘尺寸转int,再max(8,rou"
|
||
"nd(维度/8)*8);倍率1不保证尺寸不变。MAX_PIXELS=1024"
|
||
"*1024*16按输出面积分批且至少1,不是显存保证。nvidia-vfx/"
|
||
"CUDA/load/run为实现条件,运行库版本/目标设备与效果未知,不下载"
|
||
"或执行运行库。"
|
||
),
|
||
(
|
||
"LoadVideo准确核心按动态input视频枚举构造VideoFromFi"
|
||
"le;get_components静态实现会解码帧、取average_rat"
|
||
"e(缺失回退1)和可选末音轨,再包装AudioInput。文件名WanVid"
|
||
"eo_00003-audio.mp4与上传image只是源文本,不证明素材存"
|
||
"在或含声音。本轮不探测/解码视频。"
|
||
),
|
||
(
|
||
"8为VideoFromComponents,继承VideoInput默认维度"
|
||
"/时长/帧数接口;保存仅允许AUTO/MP4及AUTO/H264,实际实现h"
|
||
"264/yuv420p并将帧率取整到千分率,有audio才按采样率/帧数切片"
|
||
"后写AAC。不是保留原编码、时间戳或同步保证;实际时长、帧数、音轨/同步和编"
|
||
"码器可用性未知。"
|
||
),
|
||
(
|
||
"9保存video/ComfyUI、auto、auto。准确VideoCont"
|
||
"ainer扩展名规则auto→mp4和准确实现H264是固定源码条件,不称已"
|
||
"产出.mp4。output目录计数名、可选prompt/extra_pngi"
|
||
"nfo元数据与PreviewVideo/SavedResult的filena"
|
||
"me/subfolder/type描述符分开;描述符不是媒体字节,不请求/a"
|
||
"pi/view、不创建缓存。"
|
||
),
|
||
(
|
||
"所有五节点声明UE7.7;CreateVideo.widget_ue_con"
|
||
"nectable明确fps:true,其余空表。extra.ue_links"
|
||
"/links_added_by_ue为空只描述保存状态,不能证明无改写。准确"
|
||
"宿主先属性/序列化widgets_values后onConfigure;图级"
|
||
"fixLinkInputSlots→onGraphConfigured→原o"
|
||
"nConfigure→onAfterGraphConfigured,动态分支"
|
||
"另有恢复回调。UE实现/加载次序与最终值未知,不据宿主顺序证明扩展无影响。"
|
||
),
|
||
(
|
||
"源声明core0.16.4/frontend1.39.19,固定同一准确ta"
|
||
"g与完整commit;RTX Registry0.1.0包字节固定,Git绑"
|
||
"定未知,不借其它版本/当前main。视频schema输入顺序images/f"
|
||
"ps/audio与源物理槽images/audio/fps分开,不重排原图,"
|
||
"不造转换profile。"
|
||
),
|
||
(
|
||
"9非注释顶层保存位置=9标量(含1上传占位和1外线覆盖缓存),7空[]零位置"
|
||
";0注释/0历史对象。旧29块895保存位置+21注释逐对象不变,现30块9"
|
||
"04+21仅参考展示。155完整定稿0/必要实跑0/新增转换0,145UI仍"
|
||
"9参考候选136关闭;动态枚举、素材、设备、UE和实际效果待核。"
|
||
),
|
||
]
|
||
for e in graph["links"]:
|
||
flow.append("原边 root " + json.dumps(e, ensure_ascii=False))
|
||
for n in graph["nodes"]:
|
||
flow.append(
|
||
"原节点 root "
|
||
+ json.dumps(
|
||
{
|
||
k: n[k]
|
||
for k in ["id", "type", "mode", "inputs", "outputs", "properties"]
|
||
if k in n
|
||
},
|
||
ensure_ascii=False,
|
||
)
|
||
)
|
||
return dict(
|
||
source_path=path,
|
||
source_sha1=hashlib.sha1(raw).hexdigest(),
|
||
source_sha256=hashlib.sha256(raw).hexdigest(),
|
||
canonical_sha256=hashlib.sha256(canonical(graph)).hexdigest(),
|
||
notice="准确来源仅参考;RTX包Git绑定、UE恢复、素材/设备/编解码器与同步效果未知,转换关闭、未实跑。",
|
||
user_overview=overview,
|
||
versions=[
|
||
(
|
||
"core0.16.4→a7a6335be538f55faa2abf7404c"
|
||
"9b8e970847d1f;frontend1.39.19→d91c283b"
|
||
"7b758787b4d29126c1a9ac39dc14d6a7。"
|
||
),
|
||
"RTX准确Registry0.1.0发布包SHA另列,Git绑定未知;不借最新版。",
|
||
"五节点UE7.7;CreateVideo可连接fps:true,空扩展边记录不证明无改写,恢复/加载次序未知。",
|
||
],
|
||
counts=dict(
|
||
saved_fields=9,
|
||
source_nodes=5,
|
||
physical_edges=6,
|
||
source_notes=0,
|
||
history_objects=0,
|
||
linked_saved_fields=1,
|
||
frontend_only=1,
|
||
final_scalars=0,
|
||
final_prompt_constructed=False,
|
||
),
|
||
fields=fields,
|
||
sources=refs,
|
||
comments=[],
|
||
flow=flow,
|
||
flow_evidence=list(range(len(refs))),
|
||
zero_saved_nodes=[
|
||
dict(
|
||
node_id="7",
|
||
class_type="GetVideoComponents",
|
||
pointer="/nodes/0/widgets_values",
|
||
value=[],
|
||
effect="保存[]零位置;单视频输入拆分为images/audio/fps,不补参数。",
|
||
)
|
||
],
|
||
steps=[
|
||
overview,
|
||
"操作1:核6→7拆分、7.images→1→8及7.audio/fps→8→9六条物理边,保持停用,不上传视频。",
|
||
"操作2:区分倍率1、schema默认2.0、帧率缓存30与外线FPS;不承诺尺寸、清晰度或音画同步。",
|
||
"操作3:核video/ComfyUI和auto/auto;实际容器、编码器、音轨和保存结果待验证,不调用媒体处理。",
|
||
"常见问题:目标素材、GPU/驱动、nvidia-vfx、PyAV/编码器和UE恢复未知;当前不是可靠转换或生成入口。",
|
||
],
|
||
)
|