From a282cf18bc94730a6c718abd3e7fb21fd66ddf76 Mon Sep 17 00:00:00 2001 From: Gaurav Chahal Date: Wed, 11 Nov 2026 02:03:35 +0530 Subject: [PATCH 1/2] fix(video_compose): resolve and stage edit_decisions.audio.music for Remotion renders Resolves edit_decisions.audio.music and legacy edit_decisions.music against asset_manifest before rendering. Adapts snake_case fade fields to the camelCase properties expected by Remotion compositions (CinematicRenderer and Explainer). Ensures explicit but missing asset_ids fail loudly rather than silently rendering silence. Fixes #937 --- .../tools/test_cinematic_remotion_adapter.py | 157 ++++++++++++++++++ tools/video/video_compose.py | 139 +++++++++++++++- 2 files changed, 292 insertions(+), 4 deletions(-) diff --git a/tests/tools/test_cinematic_remotion_adapter.py b/tests/tools/test_cinematic_remotion_adapter.py index 4d8ee43fb8..5bd1d8f5e5 100644 --- a/tests/tools/test_cinematic_remotion_adapter.py +++ b/tests/tools/test_cinematic_remotion_adapter.py @@ -213,3 +213,160 @@ def test_remotion_render_rejects_cinematic_overlays_before_rendering( "CinematicRenderer does not support non-empty overlays; remove overlays " "or use a composition that supports them." ) + + +def test_resolve_music_canonical_and_legacy() -> None: + asset_lookup = { + "asset_music_bed": {"id": "asset_music_bed", "path": "path/to/bed.mp3"}, + "asset_legacy": {"id": "asset_legacy", "path": "path/to/legacy.mp3"}, + } + + # Canonical audio.music + canonical_ed = { + "audio": { + "music": { + "asset_id": "asset_music_bed", + "volume": 0.6, + "fade_in_seconds": 1.0, + "fade_out_seconds": 4.0, + "ducking": False, + } + } + } + resolved, err = VideoCompose._resolve_music(canonical_ed, asset_lookup) + assert err is None + assert resolved is not None + assert resolved["src"] == "path/to/bed.mp3" + assert resolved["volume"] == 0.6 + assert resolved["fadeInSeconds"] == 1.0 + assert resolved["fadeOutSeconds"] == 4.0 + assert resolved["ducking"] is False + + # Legacy music + legacy_ed = { + "music": { + "asset_id": "asset_legacy", + "volume": 0.3, + "fade_in_seconds": 0.5, + "fade_out_seconds": 2.0, + } + } + resolved, err = VideoCompose._resolve_music(legacy_ed, asset_lookup) + assert err is None + assert resolved is not None + assert resolved["src"] == "path/to/legacy.mp3" + assert resolved["volume"] == 0.3 + assert resolved["fadeInSeconds"] == 0.5 + assert resolved["fadeOutSeconds"] == 2.0 + + +def test_resolve_music_missing_asset_id_fails_loudly() -> None: + ed = { + "audio": { + "music": { + "asset_id": "asset_nonexistent_bed", + } + } + } + resolved, err = VideoCompose._resolve_music(ed, {}) + assert resolved is None + assert err == "Music asset_id 'asset_nonexistent_bed' not found in asset_manifest." + + +def test_render_resolves_and_stages_music_into_remotion_props(monkeypatch, tmp_path) -> None: + clip = tmp_path / "clip.mp4" + clip.write_bytes(b"dummy-clip") + music = tmp_path / "music_bed.mp3" + music.write_bytes(b"dummy-audio-content") + output = tmp_path / "out.mp4" + captured = {} + + def fake_run_command(self, command, **kwargs): + captured["command"] = command + props_arg = next(arg for arg in command if arg.startswith("--props=")) + captured["props"] = json.loads(Path(props_arg.split("=", 1)[1]).read_text()) + public_arg = next(arg for arg in command if arg.startswith("--public-dir=")) + public_dir = Path(public_arg.split("=", 1)[1]) + captured["staged_music_exists"] = ( + public_dir / captured["props"]["music"]["src"] + ).exists() + output.write_bytes(b"rendered-mp4") + + monkeypatch.setattr(VideoCompose, "run_command", fake_run_command) + monkeypatch.setattr( + VideoCompose, + "_run_final_review", + lambda self, *args, **kwargs: {"status": "pass", "issues": []}, + ) + + result = VideoCompose().execute({ + "operation": "render", + "output_path": str(output), + "edit_decisions": { + "renderer_family": "documentary-montage", + "render_runtime": "remotion", + "cuts": [ + { + "id": "c1", + "source": "asset_clip", + "in_seconds": 0, + "out_seconds": 4, + } + ], + "audio": { + "music": { + "asset_id": "asset_music_bed", + "volume": 0.6, + "fade_in_seconds": 1.0, + "fade_out_seconds": 4.0, + "ducking": False, + } + }, + }, + "asset_manifest": { + "version": "1.0", + "assets": [ + {"id": "asset_clip", "path": str(clip)}, + {"id": "asset_music_bed", "path": str(music)}, + ], + }, + }) + + assert result.success, result.error + assert captured["staged_music_exists"] is True + # Verify top-level music prop for CinematicRenderer + music_prop = captured["props"]["music"] + assert music_prop["volume"] == 0.6 + assert music_prop["fadeInSeconds"] == 1.0 + assert music_prop["fadeOutSeconds"] == 4.0 + assert music_prop["src"] != str(music) # Staged filename + # Verify audio.music prop for Explainer + assert captured["props"]["audio"]["music"]["src"] == music_prop["src"] + # 1 video clip + 1 music file = 2 staged media + assert result.data["staged_media_count"] == 2 + + +def test_render_missing_music_asset_id_returns_error(tmp_path) -> None: + clip = tmp_path / "clip.mp4" + clip.write_bytes(b"dummy-clip") + result = VideoCompose().execute({ + "operation": "render", + "output_path": str(tmp_path / "out.mp4"), + "edit_decisions": { + "renderer_family": "documentary-montage", + "render_runtime": "remotion", + "cuts": [{"id": "c1", "source": "asset_clip", "in_seconds": 0, "out_seconds": 4}], + "audio": { + "music": { + "asset_id": "asset_missing_music", + } + }, + }, + "asset_manifest": { + "version": "1.0", + "assets": [{"id": "asset_clip", "path": str(clip)}], + }, + }) + assert not result.success + assert "Music asset_id 'asset_missing_music' not found in asset_manifest." in result.error + diff --git a/tools/video/video_compose.py b/tools/video/video_compose.py index d5066e3c2a..1e366ef35c 100644 --- a/tools/video/video_compose.py +++ b/tools/video/video_compose.py @@ -479,6 +479,15 @@ def _compose(self, inputs: dict[str, Any]) -> ToolResult: output_path = Path(inputs.get("output_path", "composed_output.mp4")) output_path.parent.mkdir(parents=True, exist_ok=True) audio_path = inputs.get("audio_path") + if not audio_path and edit_decisions: + music_cfg = ( + (edit_decisions.get("audio") or {}).get("music") + or edit_decisions.get("music") + ) + if isinstance(music_cfg, dict): + cand = music_cfg.get("src") or music_cfg.get("source") or music_cfg.get("path") + if cand and Path(cand).exists(): + audio_path = str(Path(cand).resolve()) subtitle_path = inputs.get("subtitle_path") codec = inputs.get("codec", "libx264") crf = inputs.get("crf", 23) @@ -855,6 +864,100 @@ def _cuts_to_cinematic_scenes(cuts: list[dict[str, Any]]) -> list[dict[str, Any] return scenes + @classmethod + def _resolve_music( + cls, + edit_decisions: dict[str, Any], + asset_lookup: dict[str, Any], + ) -> tuple[dict[str, Any] | None, str | None]: + """Resolve music configuration from edit_decisions and asset manifest. + + Supports canonical `edit_decisions.audio.music` and legacy `edit_decisions.music`. + Resolves `asset_id` against `asset_lookup` to a local file path and adapts + snake_case fade settings (`fade_in_seconds`, `fade_out_seconds`) to the camelCase + properties (`fadeInSeconds`, `fadeOutSeconds`) expected by Remotion compositions. + + Returns (resolved_music_dict, error_string). If an explicit asset_id is present + but cannot be found in asset_lookup, returns (None, error_string) to fail loudly. + """ + music_cfg = ( + (edit_decisions.get("audio") or {}).get("music") + or edit_decisions.get("music") + ) + if not music_cfg or not isinstance(music_cfg, dict): + return None, None + + music_asset_id = music_cfg.get("asset_id") + music_source = ( + music_asset_id + or music_cfg.get("src") + or music_cfg.get("source") + or music_cfg.get("path") + ) + if not music_source: + return None, None + + resolved_path = None + if music_source in asset_lookup: + resolved_path = asset_lookup[music_source].get("path", music_source) + elif Path(music_source).exists(): + resolved_path = str(Path(music_source).resolve()) + elif music_asset_id: + return None, f"Music asset_id {music_asset_id!r} not found in asset_manifest." + else: + resolved_path = music_source + + volume = music_cfg.get("volume", 0.15) + try: + volume = float(volume) + except (TypeError, ValueError): + volume = 0.15 + + fade_in = music_cfg.get( + "fade_in_seconds", music_cfg.get("fadeInSeconds", 2.0) + ) + try: + fade_in = float(fade_in) + except (TypeError, ValueError): + fade_in = 2.0 + + fade_out = music_cfg.get( + "fade_out_seconds", music_cfg.get("fadeOutSeconds", 3.0) + ) + try: + fade_out = float(fade_out) + except (TypeError, ValueError): + fade_out = 3.0 + + resolved: dict[str, Any] = { + "src": str(resolved_path), + "volume": volume, + "fadeInSeconds": fade_in, + "fadeOutSeconds": fade_out, + "fade_in_seconds": fade_in, + "fade_out_seconds": fade_out, + } + if music_asset_id: + resolved["asset_id"] = music_asset_id + if "ducking" in music_cfg: + resolved["ducking"] = music_cfg["ducking"] + if "loop" in music_cfg: + resolved["loop"] = music_cfg["loop"] + if "trim_before_seconds" in music_cfg or "trimBeforeSeconds" in music_cfg: + resolved["trimBeforeSeconds"] = music_cfg.get( + "trim_before_seconds", music_cfg.get("trimBeforeSeconds") + ) + if "trim_after_seconds" in music_cfg or "trimAfterSeconds" in music_cfg: + resolved["trimAfterSeconds"] = music_cfg.get( + "trim_after_seconds", music_cfg.get("trimAfterSeconds") + ) + if "offset_seconds" in music_cfg or "offsetSeconds" in music_cfg: + resolved["offsetSeconds"] = music_cfg.get( + "offset_seconds", music_cfg.get("offsetSeconds") + ) + + return resolved, None + @staticmethod def _file_uri_to_raw_path(uri: str) -> str: """Convert a ``file:`` URI to a raw filesystem path string. @@ -1684,9 +1787,21 @@ def _render(self, inputs: dict[str, Any]) -> ToolResult: resolved_cut["source"] = asset_lookup[source_id]["path"] resolved_cuts.append(resolved_cut) + # Resolve music config from edit_decisions + resolved_music, music_err = self._resolve_music(edit_decisions, asset_lookup) + if music_err: + return ToolResult(success=False, error=music_err) + + resolved_edit_decisions = dict(edit_decisions, cuts=resolved_cuts) + if resolved_music: + resolved_edit_decisions["music"] = resolved_music + audio_dict = dict(resolved_edit_decisions.get("audio") or {}) + audio_dict["music"] = resolved_music + resolved_edit_decisions["audio"] = audio_dict + # --- Pre-compose validation gate --- scene_plan = inputs.get("scene_plan") - validation_block = self._pre_compose_validation(edit_decisions, resolved_cuts, scene_plan) + validation_block = self._pre_compose_validation(resolved_edit_decisions, resolved_cuts, scene_plan) if validation_block is not None: return validation_block @@ -1696,7 +1811,7 @@ def _render(self, inputs: dict[str, Any]) -> ToolResult: if render_runtime == "hyperframes": return self._render_via_hyperframes( inputs=inputs, - edit_decisions=edit_decisions, + edit_decisions=resolved_edit_decisions, asset_manifest=asset_manifest, resolved_cuts=resolved_cuts, output_path=output_path, @@ -1706,7 +1821,7 @@ def _render(self, inputs: dict[str, Any]) -> ToolResult: # Caller explicitly asked for FFmpeg — don't auto-upgrade to Remotion. return self._render_via_ffmpeg( inputs=inputs, - edit_decisions=edit_decisions, + edit_decisions=resolved_edit_decisions, resolved_cuts=resolved_cuts, output_path=output_path, profile=profile, @@ -1714,7 +1829,7 @@ def _render(self, inputs: dict[str, Any]) -> ToolResult: # --- Explicit Remotion path (render_runtime == 'remotion') --- if self._needs_remotion(resolved_cuts): remotion_inputs: dict[str, Any] = { - "edit_decisions": dict(edit_decisions, cuts=resolved_cuts), + "edit_decisions": resolved_edit_decisions, "output_path": str(output_path), } if profile: @@ -2040,6 +2155,22 @@ def _remotion_render(self, inputs: dict[str, Any]) -> ToolResult: # Deep-copy props so we don't mutate the original props = json.loads(json.dumps(composition_data)) + # Adapt audio.music <-> top-level music and snake_case <-> camelCase for Remotion + music_block = (props.get("audio") or {}).get("music") or props.get("music") + if isinstance(music_block, dict): + if "fade_in_seconds" in music_block and "fadeInSeconds" not in music_block: + music_block["fadeInSeconds"] = music_block["fade_in_seconds"] + if "fade_out_seconds" in music_block and "fadeOutSeconds" not in music_block: + music_block["fadeOutSeconds"] = music_block["fade_out_seconds"] + if "source" in music_block and "src" not in music_block: + music_block["src"] = music_block["source"] + if "music" not in props: + props["music"] = music_block + if "audio" not in props or not isinstance(props["audio"], dict): + props["audio"] = {} + if "music" not in props["audio"]: + props["audio"]["music"] = music_block + # Build a custom themeConfig from the playbook's actual colors. # This ensures every video gets a unique visual identity derived # from its production decisions — not picked from a preset menu. From 5d34656ba0fddd834cf47b71fd04f8f06a03c4ab Mon Sep 17 00:00:00 2001 From: Gaurav Chahal Date: Tue, 17 Nov 2026 04:02:43 +0530 Subject: [PATCH 2/2] fix(video_compose): address review comments for audio.music staging - Drop ffmpeg audio_path override in _compose to prevent clip audio regression [P1] - Validate resolved music file exists on disk to fail loudly on missing assets [P2] - Forward resolved_edit_decisions to compose_inputs in remotion-unavailable fallback - Mock _remotion_available in render adapter test so CI passes without node_modules [P2] - Emit only camelCase fade properties and preserve composition volume defaults --- .../tools/test_cinematic_remotion_adapter.py | 98 ++++++++++++++++++- tools/video/video_compose.py | 89 +++++++++-------- 2 files changed, 141 insertions(+), 46 deletions(-) diff --git a/tests/tools/test_cinematic_remotion_adapter.py b/tests/tools/test_cinematic_remotion_adapter.py index 5bd1d8f5e5..f2ca0846d2 100644 --- a/tests/tools/test_cinematic_remotion_adapter.py +++ b/tests/tools/test_cinematic_remotion_adapter.py @@ -215,10 +215,14 @@ def test_remotion_render_rejects_cinematic_overlays_before_rendering( ) -def test_resolve_music_canonical_and_legacy() -> None: +def test_resolve_music_canonical_and_legacy(tmp_path) -> None: + bed = tmp_path / "bed.mp3" + bed.write_bytes(b"dummy-bed") + legacy = tmp_path / "legacy.mp3" + legacy.write_bytes(b"dummy-legacy") asset_lookup = { - "asset_music_bed": {"id": "asset_music_bed", "path": "path/to/bed.mp3"}, - "asset_legacy": {"id": "asset_legacy", "path": "path/to/legacy.mp3"}, + "asset_music_bed": {"id": "asset_music_bed", "path": str(bed)}, + "asset_legacy": {"id": "asset_legacy", "path": str(legacy)}, } # Canonical audio.music @@ -236,11 +240,13 @@ def test_resolve_music_canonical_and_legacy() -> None: resolved, err = VideoCompose._resolve_music(canonical_ed, asset_lookup) assert err is None assert resolved is not None - assert resolved["src"] == "path/to/bed.mp3" + assert resolved["src"] == str(bed.resolve()) assert resolved["volume"] == 0.6 assert resolved["fadeInSeconds"] == 1.0 assert resolved["fadeOutSeconds"] == 4.0 assert resolved["ducking"] is False + assert "fade_in_seconds" not in resolved + assert "fade_out_seconds" not in resolved # Legacy music legacy_ed = { @@ -254,10 +260,33 @@ def test_resolve_music_canonical_and_legacy() -> None: resolved, err = VideoCompose._resolve_music(legacy_ed, asset_lookup) assert err is None assert resolved is not None - assert resolved["src"] == "path/to/legacy.mp3" + assert resolved["src"] == str(legacy.resolve()) assert resolved["volume"] == 0.3 assert resolved["fadeInSeconds"] == 0.5 assert resolved["fadeOutSeconds"] == 2.0 + assert "fade_in_seconds" not in resolved + assert "fade_out_seconds" not in resolved + + +def test_resolve_music_omitted_volume_and_fades_preserves_composition_defaults(tmp_path) -> None: + bed = tmp_path / "bed.mp3" + bed.write_bytes(b"dummy-bed") + asset_lookup = { + "asset_music_bed": {"id": "asset_music_bed", "path": str(bed)}, + } + ed = { + "audio": { + "music": { + "asset_id": "asset_music_bed", + } + } + } + resolved, err = VideoCompose._resolve_music(ed, asset_lookup) + assert err is None + assert resolved is not None + assert "volume" not in resolved + assert "fadeInSeconds" not in resolved + assert "fadeOutSeconds" not in resolved def test_resolve_music_missing_asset_id_fails_loudly() -> None: @@ -273,7 +302,37 @@ def test_resolve_music_missing_asset_id_fails_loudly() -> None: assert err == "Music asset_id 'asset_nonexistent_bed' not found in asset_manifest." +def test_resolve_music_missing_file_fails_loudly(tmp_path) -> None: + nonexistent = tmp_path / "nonexistent.mp3" + asset_lookup = { + "asset_music_bed": {"id": "asset_music_bed", "path": str(nonexistent)}, + } + ed = { + "audio": { + "music": { + "asset_id": "asset_music_bed", + } + } + } + resolved, err = VideoCompose._resolve_music(ed, asset_lookup) + assert resolved is None + assert err == f"Music file not found: {nonexistent}" + + # Explicit src pointing to nonexistent file + ed_src = { + "audio": { + "music": { + "src": str(nonexistent), + } + } + } + resolved2, err2 = VideoCompose._resolve_music(ed_src, {}) + assert resolved2 is None + assert err2 == f"Music file not found: {nonexistent}" + + def test_render_resolves_and_stages_music_into_remotion_props(monkeypatch, tmp_path) -> None: + monkeypatch.setattr(VideoCompose, "_remotion_available", lambda self: True) clip = tmp_path / "clip.mp4" clip.write_bytes(b"dummy-clip") music = tmp_path / "music_bed.mp3" @@ -370,3 +429,32 @@ def test_render_missing_music_asset_id_returns_error(tmp_path) -> None: assert not result.success assert "Music asset_id 'asset_missing_music' not found in asset_manifest." in result.error + +def test_render_missing_music_file_returns_error(tmp_path) -> None: + clip = tmp_path / "clip.mp4" + clip.write_bytes(b"dummy-clip") + missing_music = tmp_path / "missing_music.mp3" + result = VideoCompose().execute({ + "operation": "render", + "output_path": str(tmp_path / "out.mp4"), + "edit_decisions": { + "renderer_family": "documentary-montage", + "render_runtime": "remotion", + "cuts": [{"id": "c1", "source": "asset_clip", "in_seconds": 0, "out_seconds": 4}], + "audio": { + "music": { + "asset_id": "asset_music_bed", + } + }, + }, + "asset_manifest": { + "version": "1.0", + "assets": [ + {"id": "asset_clip", "path": str(clip)}, + {"id": "asset_music_bed", "path": str(missing_music)}, + ], + }, + }) + assert not result.success + assert f"Music file not found: {missing_music}" in result.error + diff --git a/tools/video/video_compose.py b/tools/video/video_compose.py index 1e366ef35c..8aea33bbfd 100644 --- a/tools/video/video_compose.py +++ b/tools/video/video_compose.py @@ -479,15 +479,6 @@ def _compose(self, inputs: dict[str, Any]) -> ToolResult: output_path = Path(inputs.get("output_path", "composed_output.mp4")) output_path.parent.mkdir(parents=True, exist_ok=True) audio_path = inputs.get("audio_path") - if not audio_path and edit_decisions: - music_cfg = ( - (edit_decisions.get("audio") or {}).get("music") - or edit_decisions.get("music") - ) - if isinstance(music_cfg, dict): - cand = music_cfg.get("src") or music_cfg.get("source") or music_cfg.get("path") - if cand and Path(cand).exists(): - audio_path = str(Path(cand).resolve()) subtitle_path = inputs.get("subtitle_path") codec = inputs.get("codec", "libx264") crf = inputs.get("crf", 23) @@ -900,43 +891,55 @@ def _resolve_music( resolved_path = None if music_source in asset_lookup: resolved_path = asset_lookup[music_source].get("path", music_source) - elif Path(music_source).exists(): - resolved_path = str(Path(music_source).resolve()) elif music_asset_id: return None, f"Music asset_id {music_asset_id!r} not found in asset_manifest." else: resolved_path = music_source - volume = music_cfg.get("volume", 0.15) + # Validate that the resolved file exists on disk try: - volume = float(volume) - except (TypeError, ValueError): - volume = 0.15 + if str(resolved_path).lower().startswith("file:"): + raw_file_path = cls._file_uri_to_raw_path(str(resolved_path)) + else: + raw_file_path = str(resolved_path) + file_obj = Path(raw_file_path) + if not file_obj.is_file(): + return None, f"Music file not found: {raw_file_path}" + resolved_path = str(file_obj.resolve()) + except OSError: + return None, f"Music file not found: {resolved_path}" + + resolved: dict[str, Any] = { + "src": resolved_path, + } + # Volume: only emit when explicitly provided so composition defaults apply + # (CinematicRenderer defaults to 0.15, Explainer defaults to 0.1). + if "volume" in music_cfg and music_cfg["volume"] is not None: + try: + resolved["volume"] = float(music_cfg["volume"]) + except (TypeError, ValueError): + pass + + # Fades: only emit camelCase properties expected by Remotion fade_in = music_cfg.get( - "fade_in_seconds", music_cfg.get("fadeInSeconds", 2.0) + "fadeInSeconds", music_cfg.get("fade_in_seconds") ) - try: - fade_in = float(fade_in) - except (TypeError, ValueError): - fade_in = 2.0 + if fade_in is not None: + try: + resolved["fadeInSeconds"] = float(fade_in) + except (TypeError, ValueError): + pass fade_out = music_cfg.get( - "fade_out_seconds", music_cfg.get("fadeOutSeconds", 3.0) + "fadeOutSeconds", music_cfg.get("fade_out_seconds") ) - try: - fade_out = float(fade_out) - except (TypeError, ValueError): - fade_out = 3.0 + if fade_out is not None: + try: + resolved["fadeOutSeconds"] = float(fade_out) + except (TypeError, ValueError): + pass - resolved: dict[str, Any] = { - "src": str(resolved_path), - "volume": volume, - "fadeInSeconds": fade_in, - "fadeOutSeconds": fade_out, - "fade_in_seconds": fade_in, - "fade_out_seconds": fade_out, - } if music_asset_id: resolved["asset_id"] = music_asset_id if "ducking" in music_cfg: @@ -945,15 +948,15 @@ def _resolve_music( resolved["loop"] = music_cfg["loop"] if "trim_before_seconds" in music_cfg or "trimBeforeSeconds" in music_cfg: resolved["trimBeforeSeconds"] = music_cfg.get( - "trim_before_seconds", music_cfg.get("trimBeforeSeconds") + "trimBeforeSeconds", music_cfg.get("trim_before_seconds") ) if "trim_after_seconds" in music_cfg or "trimAfterSeconds" in music_cfg: resolved["trimAfterSeconds"] = music_cfg.get( - "trim_after_seconds", music_cfg.get("trimAfterSeconds") + "trimAfterSeconds", music_cfg.get("trim_after_seconds") ) if "offset_seconds" in music_cfg or "offsetSeconds" in music_cfg: resolved["offsetSeconds"] = music_cfg.get( - "offset_seconds", music_cfg.get("offsetSeconds") + "offsetSeconds", music_cfg.get("offset_seconds") ) return resolved, None @@ -1883,7 +1886,7 @@ def _render(self, inputs: dict[str, Any]) -> ToolResult: # Build compose inputs compose_inputs = dict(inputs) - compose_inputs["edit_decisions"] = dict(edit_decisions, cuts=resolved_cuts) + compose_inputs["edit_decisions"] = dict(resolved_edit_decisions, cuts=resolved_cuts) compose_inputs["output_path"] = str(output_path) if subtitle_path: compose_inputs["subtitle_path"] = subtitle_path @@ -2158,10 +2161,14 @@ def _remotion_render(self, inputs: dict[str, Any]) -> ToolResult: # Adapt audio.music <-> top-level music and snake_case <-> camelCase for Remotion music_block = (props.get("audio") or {}).get("music") or props.get("music") if isinstance(music_block, dict): - if "fade_in_seconds" in music_block and "fadeInSeconds" not in music_block: - music_block["fadeInSeconds"] = music_block["fade_in_seconds"] - if "fade_out_seconds" in music_block and "fadeOutSeconds" not in music_block: - music_block["fadeOutSeconds"] = music_block["fade_out_seconds"] + if "fade_in_seconds" in music_block: + if "fadeInSeconds" not in music_block: + music_block["fadeInSeconds"] = music_block["fade_in_seconds"] + del music_block["fade_in_seconds"] + if "fade_out_seconds" in music_block: + if "fadeOutSeconds" not in music_block: + music_block["fadeOutSeconds"] = music_block["fade_out_seconds"] + del music_block["fade_out_seconds"] if "source" in music_block and "src" not in music_block: music_block["src"] = music_block["source"] if "music" not in props: