diff --git a/CHANGELOG.md b/CHANGELOG.md index 20b2f93..bd04b10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### ⚡ Improvements +- **MultiTrack Project**: The inter-segment context overlap is now configurable. The new `context_frames` widget (5 / 22 / 39 / 56 frames, default 22) chooses how many frames of the previous segment are copied in as continuation context for segments using Context or Context Swap continuity — previously this was fixed at 22 frames in code. Longer values hand off motion more smoothly but generate that many extra frames per continued segment (each continuation also generates 12 grid-alignment tail frames that are trimmed after decode). Values are the H3 temporal-grid lengths already offered by the Moxie context sampler nodes; existing workflows keep 22 and behave exactly as before. + - **Moxie Multimedia Loader**: Removed the automatic LoRA application entirely. The 3-step distill (speedup) weights are now baked into the diffusion model itself, so the loader no longer reads `models/loras` — a leftover file there is silently ignored, and the `models/loras` folder can be deleted. The node schema, outputs, and load order (diffusion model → attention backend → CLIP → VAEs) are unchanged; workflows saved earlier keep working. The `Moxie Project` steps tooltip now references the baked-in distill instead of the LoRA. - **FFmpeg resolution & diagnostics**: The pack now finds FFmpeg on far more Windows setups and tells you exactly what is wrong when it cannot. When `ffmpeg` is not on the ComfyUI process's PATH (PATH edits only reach processes started afterwards), it is additionally looked up in the classic `C:\ffmpeg\bin`, the ComfyUI/portable folders (including `ffmpeg\bin` next to the run bat), winget/scoop/chocolatey shim locations, and finally the ffmpeg binary bundled with ComfyUI's own `imageio-ffmpeg` dependency. When composing an H3 project still fails, the error dialog now names the concrete cause instead of a generic message: the missing executable, the exact missing segment/locked-audio file paths, odd canvas sizes, or the tail of FFmpeg's own stderr output (e.g. `Unknown encoder 'libx264'`). - **Installation**: The pack now ships a **`requirements.txt`**, so ComfyUI Manager installs the dependencies automatically and manual/portable installs have a one-line command (`python_embeded\python.exe -m pip install -r ...` for ComfyUI Portable — see the new "Installing dependencies" section in the README). Because this pack targets **NVIDIA RTX 3060+ GPUs only**, every feature dependency is mandatory: `soundfile`, `jieba`, `huggingface_hub`, `ffmpeg-python`, `opencv-python`, `imageio` (smart split), `nvidia-vfx` (RTX VSR upscale), `openai-whisper` and `qwen-asr` (subtitle recognition), and `voxcpm` (speech). No optional extras remain — previously these were installed on demand with error messages naming the missing package. The file also routes `nvidia-vfx` to NVIDIA's own index (`--extra-index-url https://pypi.nvidia.com/` + `--only-binary=nvidia-vfx`): the PyPI copy is a stub sdist whose `wheel_stub` build backend can abort the whole install (`Cannot import 'wheel_stub.buildapi'`), while NVIDIA's index serves real prebuilt wheels. diff --git a/nodes/project.py b/nodes/project.py index 2ecbf07..405017d 100644 --- a/nodes/project.py +++ b/nodes/project.py @@ -54,6 +54,12 @@ TYPE_PROJECT_DATA = io.Custom(io_type="PROJECT_DATA") TYPE_H3_PROJECT_STATIC_DATA = io.Custom(io_type="H3_PROJECT_STATIC_DATA") H3_CONTEXT_CONTINUITY_MODES = {"context", "context_swap"} H3_CONTEXT_SOURCE_FRAMES = 22 +# Context lengths supported by the H3 continuation sampler nodes; every +# value lands on the H3 temporal latent grid (17k + 5 frames). +H3_CONTEXT_LENGTH_OPTIONS = (5, 22, 39, 56) +# Extra frames generated past the context prefix so the decoded clip ends +# on a phase-aligned H3 grid boundary before the tail is trimmed. +H3_CONTEXT_GRID_TAIL_FRAMES = 12 def _first_input(value: Any, default: Any = None) -> Any: @@ -62,6 +68,18 @@ def _first_input(value: Any, default: Any = None) -> Any: return value if value is not None else default +def _h3_context_frame_count(value: Any) -> int: + """Resolve the context_frames widget to a supported H3 context length.""" + frames = int(_first_input(value, str(H3_CONTEXT_SOURCE_FRAMES))) + if frames not in H3_CONTEXT_LENGTH_OPTIONS: + options = ", ".join(str(option) for option in H3_CONTEXT_LENGTH_OPTIONS) + raise ValueError( + "context_frames must be one of the supported H3 context lengths: " + f"{options} (got {frames})" + ) + return frames + + def _raw_project_input(value: Any) -> Any: """Unwrap list inputs without splitting a raw graph link.""" if is_link(value): @@ -930,6 +948,19 @@ class EasyMultiTrackProject(io.ComfyNode): "mode preserves existing video and latent files." ), ), + io.Combo.Input( + "context_frames", + options=[str(option) for option in H3_CONTEXT_LENGTH_OPTIONS], + default=str(H3_CONTEXT_SOURCE_FRAMES), + tooltip=( + "Video frames copied from the previous segment as " + "continuation context for segments whose continuity " + "mode is Context or Context Swap. Longer values hand " + "off motion more smoothly but generate that many extra " + "frames per segment. Values are H3 temporal-grid " + "lengths shared with the Moxie context sampler nodes." + ), + ), io.Int.Input( "seed", default=42, @@ -1090,6 +1121,9 @@ class EasyMultiTrackProject(io.ComfyNode): sampling_mode, sampling_config = _h3_sampling_mode_config( kwargs.get("sampling_mode") ) + context_source_frames = _h3_context_frame_count( + kwargs.get("context_frames") + ) is_passthrough = sampling_mode == "passthrough" is_selflift = sampling_mode == "selflift" has_second_pass = sampling_mode == "dual" @@ -1502,12 +1536,13 @@ class EasyMultiTrackProject(io.ComfyNode): context_latent = _h3_encode_context_media( graph, output_images, output_audio, vae, audio_vae, f"passthrough_context_{task_index}", + context_frames=context_source_frames, ) runtime_context_latent = graph.node( "easy h3MotionContextLatentTrim", id=f"trim_hires_context_latent_{task_index}", latent=context_latent, - context_length=str(H3_CONTEXT_SOURCE_FRAMES), + context_length=str(context_source_frames), ).out(0) saved_video = graph.node( "easy saveVideo", @@ -1568,8 +1603,9 @@ class EasyMultiTrackProject(io.ComfyNode): uses_context and (previous_hires_context_latent is not None or task_index > 0) ) - context_source_frames = H3_CONTEXT_SOURCE_FRAMES - context_generation_frames = 34 + context_generation_frames = ( + context_source_frames + H3_CONTEXT_GRID_TAIL_FRAMES + ) if will_have_context_continuity: task_length = graph.node( "ComfyMathExpression", @@ -1926,7 +1962,7 @@ class EasyMultiTrackProject(io.ComfyNode): id=f"hires_continuity_{task_index}", current_hires_latent=upscaled_latent, previous_hires_latent=previous_hires_context_latent, - context_length=str(H3_CONTEXT_SOURCE_FRAMES), + context_length=str(context_source_frames), video_transition_steps=4, video_anchor_only=not audio_only, ) @@ -2116,6 +2152,7 @@ class EasyMultiTrackProject(io.ComfyNode): vae, audio_vae, f"hires_context_{task_index}", + context_frames=context_source_frames, ) hires_context_reencoded = True if (has_second_pass and run_second_pass) or ( @@ -2159,6 +2196,7 @@ class EasyMultiTrackProject(io.ComfyNode): vae, audio_vae, f"low_context_{task_index}", + context_frames=context_source_frames, ) low_context_reencoded = True else: diff --git a/skills/easy-media-multitrack-workflow/references/multitrack-schema.md b/skills/easy-media-multitrack-workflow/references/multitrack-schema.md index 6d30fc1..394385b 100644 --- a/skills/easy-media-multitrack-workflow/references/multitrack-schema.md +++ b/skills/easy-media-multitrack-workflow/references/multitrack-schema.md @@ -266,6 +266,7 @@ custom 示例: - `segment_count = -1` 表示从起始索引处理到末尾;非负数限制本次任务片段数量。 - `project_save`: `new` 或 `override`。在 `override` 且 count 为 `-1` 时,执行逻辑会删除起始索引之后的已保存片段再生成;修改前向用户清楚说明。 - `sampling_mode`: `single` 或 `dual`;`sampling_plan` 必须是当前节点可用预设。不要仅凭另一份流程中的值假设当前环境支持。 +- `context_frames`(默认 `"22"`,可选 `"5"` / `"22"` / `"39"` / `"56"`)控制 Context / Context Swap 续接片段从上一段拷贝为延续上下文的视频帧数;取值必须落在 H3 时间潜空间网格(17k+5 帧)上,与 Moxie 上下文采样节点的选项一致。数值越大运动衔接越平滑,但每个续接片段会多生成等量帧(实际生成长度为 `任务长度 + context_frames + 12`,其中 12 帧为网格尾帧,解码后裁掉)。 - 编辑器分辨率是一采尺寸;`dual` 不会反算缩小一采。二采宽高分别为 `round(编辑器尺寸 * upscale_by / 32) * 32`,采用 Python `round` 就近对齐,恰好居中时取偶数,不是固定向上对齐。 - `upscale_by` 是 Project 的独立参数,默认 `1.250`,三位小数,步长 `0.001`;旧工作流保留已保存的值。两条放大路径及合并导出均使用放大并对齐后的尺寸。例如 `1344 × 768`、倍率 `1.250` 的二采为 `1664 × 960`。若用户指定最终输出尺寸,应同时核对编辑器尺寸与倍率,不能将编辑器尺寸直接当作双采样的最终尺寸。 - 单采样、仅一采预览保持编辑器尺寸;`upscale_by = 1.000` 不放大但可二采;纯音频项目(`32 × 32`)不放大。旧版反算缩小尺寸的一采检查点和上下文潜空间应重新生成后再按新规则续跑。 @@ -290,6 +291,7 @@ Plan 只包含实际变更。`node_id` 可省略并由拓扑定位;`editor.res "project_save": "override", "segment_start_number": 1, "segment_count": -1, + "context_frames": "22", "sampling_plan": "medium", "sampling_mode": "single" } diff --git a/tests/test_minimax_node.py b/tests/test_minimax_node.py index 15ed3fd..515cd12 100644 --- a/tests/test_minimax_node.py +++ b/tests/test_minimax_node.py @@ -1238,6 +1238,7 @@ def test_multitrack_h3_project_schema_exposes_pipeline_configuration(monkeypatch "project_save", "segment_start_number", "segment_count", + "context_frames", "seed", "sampling_plan", "sampling_mode", @@ -1259,6 +1260,8 @@ def test_multitrack_h3_project_schema_exposes_pipeline_configuration(monkeypatch assert inputs["project_name"].kwargs["default"] == "" assert inputs["project_save"].kwargs["options"] == ["new", "override"] assert inputs["project_save"].kwargs["default"] == "override" + assert inputs["context_frames"].kwargs["options"] == ["5", "22", "39", "56"] + assert inputs["context_frames"].kwargs["default"] == "22" sampling_plan_options = inputs["sampling_plan"].kwargs["options"] assert sampling_plan_options == [ "custom", @@ -3749,6 +3752,89 @@ def test_multitrack_h3_context_chain_uses_previous_segment_latent(monkeypatch): assert artifacts[1][1]["inputs"]["previous"] == [artifacts[0][0], 0] +def test_multitrack_context_frames_widget_propagates(monkeypatch): + module = _load_minimax_node(monkeypatch) + assert module is not None + module.comfy_nodes.NODE_CLASS_MAPPINGS["MiniMaxH3MotionContextTrim"] = ( + _MiniMaxMotionContextTrim + ) + info = _h3_project_inputs()["tracks_info"][0] + info["tracks"][0]["segments"].append( + { + "start_frame": 120, + "end_frame": 240, + "content": { + "task_mode": "l2v", + "continuity_mode": "context", + "images": [{"media_index": 0}], + "user_prompt": "continue", + }, + } + ) + info["tracks"].append( + { + "id": "locked-audio-track", + "type": "audio", + "audio_locked": True, + "segments": [ + { + "id": "locked-audio", + "start_frame": 0, + "end_frame": 240, + "content": {"media_type": "audio"}, + } + ], + } + ) + + result = module.EasyMultiTrackProject.execute( + **_h3_project_inputs(tracks_info=[info], context_frames=["5"]) + ) + + motion = next( + node + for node in result.expand.values() + if node["class_type"] == "easy MiniMaxH3MotionContextHard" + ) + assert motion["inputs"]["context_length"] == "5" + context_trims = [ + node + for node in result.expand.values() + if node["class_type"] == "easy h3MotionContextLatentTrim" + ] + assert context_trims + assert {trim["inputs"]["context_length"] for trim in context_trims} == {"5"} + audio_locks = [ + node + for node in result.expand.values() + if node["class_type"] == "easy minimaxH3AudioLock" + ] + assert sorted(node["inputs"]["prepend_frames"] for node in audio_locks) == [0, 5] + math_node = next( + node + for node in result.expand.values() + if node["class_type"] == "ComfyMathExpression" + ) + # The context continuation generates context_frames + 12 grid-tail frames. + assert math_node["inputs"]["expression"] == "a + 17" + context_encodes = [ + node + for node in result.expand.values() + if node["class_type"] == "easy h3ContextMediaTrim" + and node["inputs"]["output_frames"] == 5 + ] + assert context_encodes + + +def test_multitrack_context_frames_widget_rejects_off_grid_values(monkeypatch): + module = _load_minimax_node(monkeypatch) + assert module is not None + with pytest.raises(ValueError, match="supported H3 context lengths"): + module.EasyMultiTrackProject.execute( + **_h3_project_inputs(context_frames=["18"]) + ) + + def test_multitrack_h3_context_uses_embedded_five_frame_anchor(monkeypatch): module = _load_minimax_node(monkeypatch) info = _h3_project_inputs()["tracks_info"][0]