braidio 0.0.90__tar.gz → 0.0.91__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. {braidio-0.0.90 → braidio-0.0.91}/PKG-INFO +1 -1
  2. {braidio-0.0.90 → braidio-0.0.91}/braidio/transforms/__init__.py +53 -1
  3. {braidio-0.0.90 → braidio-0.0.91}/braidio/transforms/_video_cut.py +86 -12
  4. {braidio-0.0.90 → braidio-0.0.91}/pyproject.toml +1 -1
  5. {braidio-0.0.90 → braidio-0.0.91}/tests/test_nw_app.py +21 -0
  6. {braidio-0.0.90 → braidio-0.0.91}/tests/test_video_transforms.py +50 -0
  7. {braidio-0.0.90 → braidio-0.0.91}/.editorconfig +0 -0
  8. {braidio-0.0.90 → braidio-0.0.91}/.gitattributes +0 -0
  9. {braidio-0.0.90 → braidio-0.0.91}/.gitignore +0 -0
  10. {braidio-0.0.90 → braidio-0.0.91}/LICENSE +0 -0
  11. {braidio-0.0.90 → braidio-0.0.91}/README.md +0 -0
  12. {braidio-0.0.90 → braidio-0.0.91}/braidio/__init__.py +0 -0
  13. {braidio-0.0.90 → braidio-0.0.91}/braidio/_paths.py +0 -0
  14. {braidio-0.0.90 → braidio-0.0.91}/braidio/bodies/__init__.py +0 -0
  15. {braidio-0.0.90 → braidio-0.0.91}/braidio/bodies/_domain.py +0 -0
  16. {braidio-0.0.90 → braidio-0.0.91}/braidio/bodies/_render_nodes.py +0 -0
  17. {braidio-0.0.90 → braidio-0.0.91}/braidio/bodies/_tiers.py +0 -0
  18. {braidio-0.0.90 → braidio-0.0.91}/braidio/bodies/_video.py +0 -0
  19. {braidio-0.0.90 → braidio-0.0.91}/braidio/captions.py +0 -0
  20. {braidio-0.0.90 → braidio-0.0.91}/braidio/compose.py +0 -0
  21. {braidio-0.0.90 → braidio-0.0.91}/braidio/conversation.py +0 -0
  22. {braidio-0.0.90 → braidio-0.0.91}/braidio/cost.py +0 -0
  23. {braidio-0.0.90 → braidio-0.0.91}/braidio/data/skills/braidio/SKILL.md +0 -0
  24. {braidio-0.0.90 → braidio-0.0.91}/braidio/data/skills/braidio-commentary-video/SKILL.md +0 -0
  25. {braidio-0.0.90 → braidio-0.0.91}/braidio/defaults.py +0 -0
  26. {braidio-0.0.90 → braidio-0.0.91}/braidio/delivery.py +0 -0
  27. {braidio-0.0.90 → braidio-0.0.91}/braidio/downloads.py +0 -0
  28. {braidio-0.0.90 → braidio-0.0.91}/braidio/formats.py +0 -0
  29. {braidio-0.0.90 → braidio-0.0.91}/braidio/genre.py +0 -0
  30. {braidio-0.0.90 → braidio-0.0.91}/braidio/importing/__init__.py +0 -0
  31. {braidio-0.0.90 → braidio-0.0.91}/braidio/importing/__main__.py +0 -0
  32. {braidio-0.0.90 → braidio-0.0.91}/braidio/importing/_catalog.py +0 -0
  33. {braidio-0.0.90 → braidio-0.0.91}/braidio/importing/_manifest.py +0 -0
  34. {braidio-0.0.90 → braidio-0.0.91}/braidio/importing/_writer.py +0 -0
  35. {braidio-0.0.90 → braidio-0.0.91}/braidio/kinds.py +0 -0
  36. {braidio-0.0.90 → braidio-0.0.91}/braidio/leveling.py +0 -0
  37. {braidio-0.0.90 → braidio-0.0.91}/braidio/markdown_script.py +0 -0
  38. {braidio-0.0.90 → braidio-0.0.91}/braidio/mcp/__init__.py +0 -0
  39. {braidio-0.0.90 → braidio-0.0.91}/braidio/mcp/_docs.py +0 -0
  40. {braidio-0.0.90 → braidio-0.0.91}/braidio/mcp/_guide.py +0 -0
  41. {braidio-0.0.90 → braidio-0.0.91}/braidio/mcp/_helpers.py +0 -0
  42. {braidio-0.0.90 → braidio-0.0.91}/braidio/mcp/_media.py +0 -0
  43. {braidio-0.0.90 → braidio-0.0.91}/braidio/mcp/credentials.py +0 -0
  44. {braidio-0.0.90 → braidio-0.0.91}/braidio/mcp/metering.py +0 -0
  45. {braidio-0.0.90 → braidio-0.0.91}/braidio/mcp/tools.py +0 -0
  46. {braidio-0.0.90 → braidio-0.0.91}/braidio/mcp/workspace.py +0 -0
  47. {braidio-0.0.90 → braidio-0.0.91}/braidio/multivoice.py +0 -0
  48. {braidio-0.0.90 → braidio-0.0.91}/braidio/music.py +0 -0
  49. {braidio-0.0.90 → braidio-0.0.91}/braidio/pacing.py +0 -0
  50. {braidio-0.0.90 → braidio-0.0.91}/braidio/project.py +0 -0
  51. {braidio-0.0.90 → braidio-0.0.91}/braidio/provenance.py +0 -0
  52. {braidio-0.0.90 → braidio-0.0.91}/braidio/relevance.py +0 -0
  53. {braidio-0.0.90 → braidio-0.0.91}/braidio/render.py +0 -0
  54. {braidio-0.0.90 → braidio-0.0.91}/braidio/rights.py +0 -0
  55. {braidio-0.0.90 → braidio-0.0.91}/braidio/script.py +0 -0
  56. {braidio-0.0.90 → braidio-0.0.91}/braidio/sources.py +0 -0
  57. {braidio-0.0.90 → braidio-0.0.91}/braidio/structure.py +0 -0
  58. {braidio-0.0.90 → braidio-0.0.91}/braidio/style.py +0 -0
  59. {braidio-0.0.90 → braidio-0.0.91}/braidio/textprep.py +0 -0
  60. {braidio-0.0.90 → braidio-0.0.91}/braidio/timeline.py +0 -0
  61. {braidio-0.0.90 → braidio-0.0.91}/braidio/transforms/_asset_refs.py +0 -0
  62. {braidio-0.0.90 → braidio-0.0.91}/braidio/transforms/_common.py +0 -0
  63. {braidio-0.0.90 → braidio-0.0.91}/braidio/transforms/_dialogue.py +0 -0
  64. {braidio-0.0.90 → braidio-0.0.91}/braidio/transforms/_episode.py +0 -0
  65. {braidio-0.0.90 → braidio-0.0.91}/braidio/transforms/_ingest.py +0 -0
  66. {braidio-0.0.90 → braidio-0.0.91}/braidio/transforms/_narration.py +0 -0
  67. {braidio-0.0.90 → braidio-0.0.91}/braidio/transforms/_segment.py +0 -0
  68. {braidio-0.0.90 → braidio-0.0.91}/braidio/transforms/_video_panels.py +0 -0
  69. {braidio-0.0.90 → braidio-0.0.91}/braidio/transforms/_voice.py +0 -0
  70. {braidio-0.0.90 → braidio-0.0.91}/braidio/tts.py +0 -0
  71. {braidio-0.0.90 → braidio-0.0.91}/braidio/video.py +0 -0
  72. {braidio-0.0.90 → braidio-0.0.91}/braidio/voice_library.py +0 -0
  73. {braidio-0.0.90 → braidio-0.0.91}/braidio/weave.py +0 -0
  74. {braidio-0.0.90 → braidio-0.0.91}/braidio/weave_config.py +0 -0
  75. {braidio-0.0.90 → braidio-0.0.91}/conftest.py +0 -0
  76. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/Extraction and nw-App Design.md +0 -0
  77. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/research/commentary-formats-and-styles.md +0 -0
  78. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/research/conversational-vs-narration-tts.md +0 -0
  79. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/research/notebooklm-and-conversational-pacing.md +0 -0
  80. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/README.md +0 -0
  81. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/anti-platitude-checklist.md +0 -0
  82. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/commentary-voice-guide.md +0 -0
  83. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/_style-groups.md +0 -0
  84. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/amanda-dobbins.md +0 -0
  85. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/david-sims.md +0 -0
  86. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/griffin-newman.md +0 -0
  87. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/helen-molesworth.md +0 -0
  88. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/hrishikesh-hirway.md +0 -0
  89. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/jason-mantzoukas.md +0 -0
  90. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/john-mcwhorter.md +0 -0
  91. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/jon-caramanica.md +0 -0
  92. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/june-diane-raphael.md +0 -0
  93. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/karina-longworth.md +0 -0
  94. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/katy-hessel.md +0 -0
  95. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/louis-theroux.md +0 -0
  96. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/mallory-rubin.md +0 -0
  97. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/melvyn-bragg.md +0 -0
  98. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/michael-barbaro.md +0 -0
  99. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/nate-sloan-charlie-harding.md +0 -0
  100. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/paul-scheer.md +0 -0
  101. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/sean-fennessey.md +0 -0
  102. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/talk-art.md +0 -0
  103. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/style/voices/yasi-salek.md +0 -0
  104. {braidio-0.0.90 → braidio-0.0.91}/misc/docs/youtube_ingest_credentials.md +0 -0
  105. {braidio-0.0.90 → braidio-0.0.91}/tests/_audio.py +0 -0
  106. {braidio-0.0.90 → braidio-0.0.91}/tests/test_body_schema_stability.py +0 -0
  107. {braidio-0.0.90 → braidio-0.0.91}/tests/test_conversation.py +0 -0
  108. {braidio-0.0.90 → braidio-0.0.91}/tests/test_cost.py +0 -0
  109. {braidio-0.0.90 → braidio-0.0.91}/tests/test_credits_card.py +0 -0
  110. {braidio-0.0.90 → braidio-0.0.91}/tests/test_defaults.py +0 -0
  111. {braidio-0.0.90 → braidio-0.0.91}/tests/test_delivery.py +0 -0
  112. {braidio-0.0.90 → braidio-0.0.91}/tests/test_downloads.py +0 -0
  113. {braidio-0.0.90 → braidio-0.0.91}/tests/test_expressiveness.py +0 -0
  114. {braidio-0.0.90 → braidio-0.0.91}/tests/test_formats.py +0 -0
  115. {braidio-0.0.90 → braidio-0.0.91}/tests/test_genre_placement.py +0 -0
  116. {braidio-0.0.90 → braidio-0.0.91}/tests/test_graph_speak.py +0 -0
  117. {braidio-0.0.90 → braidio-0.0.91}/tests/test_importing.py +0 -0
  118. {braidio-0.0.90 → braidio-0.0.91}/tests/test_leveling.py +0 -0
  119. {braidio-0.0.90 → braidio-0.0.91}/tests/test_markdown_script.py +0 -0
  120. {braidio-0.0.90 → braidio-0.0.91}/tests/test_mcp.py +0 -0
  121. {braidio-0.0.90 → braidio-0.0.91}/tests/test_mcp_caller_key.py +0 -0
  122. {braidio-0.0.90 → braidio-0.0.91}/tests/test_media_auth.py +0 -0
  123. {braidio-0.0.90 → braidio-0.0.91}/tests/test_multivoice.py +0 -0
  124. {braidio-0.0.90 → braidio-0.0.91}/tests/test_music.py +0 -0
  125. {braidio-0.0.90 → braidio-0.0.91}/tests/test_namespaced_source.py +0 -0
  126. {braidio-0.0.90 → braidio-0.0.91}/tests/test_pacing.py +0 -0
  127. {braidio-0.0.90 → braidio-0.0.91}/tests/test_packaging.py +0 -0
  128. {braidio-0.0.90 → braidio-0.0.91}/tests/test_render_settings.py +0 -0
  129. {braidio-0.0.90 → braidio-0.0.91}/tests/test_script.py +0 -0
  130. {braidio-0.0.90 → braidio-0.0.91}/tests/test_sources.py +0 -0
  131. {braidio-0.0.90 → braidio-0.0.91}/tests/test_speak_seam.py +0 -0
  132. {braidio-0.0.90 → braidio-0.0.91}/tests/test_structure.py +0 -0
  133. {braidio-0.0.90 → braidio-0.0.91}/tests/test_textprep_style.py +0 -0
  134. {braidio-0.0.90 → braidio-0.0.91}/tests/test_timeline.py +0 -0
  135. {braidio-0.0.90 → braidio-0.0.91}/tests/test_transforms.py +0 -0
  136. {braidio-0.0.90 → braidio-0.0.91}/tests/test_transforms_dialogue.py +0 -0
  137. {braidio-0.0.90 → braidio-0.0.91}/tests/test_transforms_episode_members.py +0 -0
  138. {braidio-0.0.90 → braidio-0.0.91}/tests/test_transforms_rights.py +0 -0
  139. {braidio-0.0.90 → braidio-0.0.91}/tests/test_transforms_secrets.py +0 -0
  140. {braidio-0.0.90 → braidio-0.0.91}/tests/test_transforms_structure.py +0 -0
  141. {braidio-0.0.90 → braidio-0.0.91}/tests/test_tts_api_key.py +0 -0
  142. {braidio-0.0.90 → braidio-0.0.91}/tests/test_turn_overlap.py +0 -0
  143. {braidio-0.0.90 → braidio-0.0.91}/tests/test_video.py +0 -0
  144. {braidio-0.0.90 → braidio-0.0.91}/tests/test_video_bodies.py +0 -0
  145. {braidio-0.0.90 → braidio-0.0.91}/tests/test_video_footage.py +0 -0
  146. {braidio-0.0.90 → braidio-0.0.91}/tests/test_voice_library.py +0 -0
  147. {braidio-0.0.90 → braidio-0.0.91}/tests/test_weave.py +0 -0
  148. {braidio-0.0.90 → braidio-0.0.91}/tests/test_weave_config.py +0 -0
  149. {braidio-0.0.90 → braidio-0.0.91}/tests/test_weave_master.py +0 -0
  150. {braidio-0.0.90 → braidio-0.0.91}/tests/test_wire_descriptions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: braidio
3
- Version: 0.0.90
3
+ Version: 0.0.91
4
4
  Summary: Weave narration with extracted media segments into audiovisual productions
5
5
  Project-URL: Homepage, https://github.com/thorwhalen/braidio
6
6
  Project-URL: Repository, https://github.com/thorwhalen/braidio
@@ -37,7 +37,29 @@ from __future__ import annotations
37
37
 
38
38
  from nw import TransformInputs
39
39
 
40
- from braidio.transforms._common import ELEVENLABS_SECRET
40
+ from braidio.transforms._common import (
41
+ ELEVENLABS_SECRET,
42
+ TIER_WEAVE_CONFIG,
43
+ TIER_PRODUCTION_STRUCTURE,
44
+ TIER_RENDER_PROFILE,
45
+ TIER_DIALOGUE_CAST,
46
+ TIER_SOURCE_MEDIA,
47
+ TIER_NARRATIVE_BEAT,
48
+ TIER_DIALOGUE_BEAT,
49
+ TIER_SCENE_BREAK,
50
+ TIER_AUDIO_CLIP,
51
+ TIER_VOICE_ASSIGNMENT,
52
+ TIER_NARRATION_RENDER,
53
+ TIER_DIALOGUE_RENDER,
54
+ TIER_SEGMENT_EXTRACTION,
55
+ TIER_EPISODE_RENDER,
56
+ TIER_STILL,
57
+ TIER_VIDEO_PANEL,
58
+ TIER_VIDEO_CUT,
59
+ TIER_LABEL_TRACK,
60
+ graph_index,
61
+ node_ref,
62
+ )
41
63
  from braidio.weave_config import WeaveConfig
42
64
  from braidio.transforms._ingest import ingest_script, IngestedScript
43
65
  from braidio.transforms import ( # noqa: F401
@@ -66,7 +88,11 @@ from braidio.transforms._video_panels import (
66
88
  tracks_for_episode,
67
89
  )
68
90
  from braidio.transforms._video_cut import (
91
+ content_keyed_prepare,
92
+ frames_dir,
93
+ panel_canvas,
69
94
  panel_footage,
95
+ panel_source,
70
96
  panel_path,
71
97
  path_for_panel,
72
98
  path_on_canvas,
@@ -111,6 +137,32 @@ __all__ = [
111
137
  "path_for_panel",
112
138
  "path_on_canvas",
113
139
  "resolve_move",
140
+ # what a host reads the picture track with (braidio#146)
141
+ "content_keyed_prepare",
142
+ "frames_dir",
143
+ "panel_canvas",
144
+ "panel_source",
145
+ # reading the project graph: one index, a tier's ref, and every tier name
146
+ "graph_index",
147
+ "node_ref",
148
+ "TIER_WEAVE_CONFIG",
149
+ "TIER_PRODUCTION_STRUCTURE",
150
+ "TIER_RENDER_PROFILE",
151
+ "TIER_DIALOGUE_CAST",
152
+ "TIER_SOURCE_MEDIA",
153
+ "TIER_NARRATIVE_BEAT",
154
+ "TIER_DIALOGUE_BEAT",
155
+ "TIER_SCENE_BREAK",
156
+ "TIER_AUDIO_CLIP",
157
+ "TIER_VOICE_ASSIGNMENT",
158
+ "TIER_NARRATION_RENDER",
159
+ "TIER_DIALOGUE_RENDER",
160
+ "TIER_SEGMENT_EXTRACTION",
161
+ "TIER_EPISODE_RENDER",
162
+ "TIER_STILL",
163
+ "TIER_VIDEO_PANEL",
164
+ "TIER_VIDEO_CUT",
165
+ "TIER_LABEL_TRACK",
114
166
  "VOICE_ASSIGNMENT_TRANSFORM",
115
167
  "NARRATION_RENDER_TRANSFORM",
116
168
  "DIALOGUE_RENDER_TRANSFORM",
@@ -926,13 +926,20 @@ def _crop_still(
926
926
  return dst
927
927
 
928
928
 
929
- def _content_keyed_prepare(workdir: Path, size: tuple[int, int]):
929
+ def content_keyed_prepare(workdir: Path, size: tuple[int, int]):
930
930
  """A ``prepare=`` for :func:`braidio.video.render_video` that names each
931
931
  canvas by the source's **bytes** and the frame size — never by its
932
932
  ordinal or its filename stem. ``render_video``'s default naming
933
933
  (``{i:03d}_{stem}.jpg``) plus ``prepare_still``'s existing-file shortcut
934
934
  would otherwise serve a stale canvas for a swapped still with the same
935
935
  stem, or a landscape canvas to a vertical cut.
936
+
937
+ Returns ``prepare(src, dst_ignored, *, size=size) -> Path``: the canvas
938
+ for the picture at ``src``, written under ``workdir``. ``dst_ignored`` is
939
+ there only to fit ``render_video``'s ``prepare`` signature; a caller of
940
+ its own passes ``None``. To get the canvas a panel is framed on, call
941
+ :func:`panel_canvas` instead — it is this, over :func:`panel_source`, in
942
+ one call.
936
943
  """
937
944
  from braidio.video import prepare_still
938
945
 
@@ -944,14 +951,26 @@ def _content_keyed_prepare(workdir: Path, size: tuple[int, int]):
944
951
  return prepare
945
952
 
946
953
 
947
- def _frames_dir(project) -> Path:
954
+ def frames_dir(project) -> Path:
948
955
  """Where prepared canvases and cropped stills are cached (shared by the
949
956
  render and :func:`panel_path`, so a preview warms the render's cache)."""
950
957
  return _cuts_dir(project) / "_frames"
951
958
 
952
959
 
953
- def _panel_source(project, panel: Annotation, index: dict, workdir: Path) -> Path:
954
- """The picture a panel shows: its still's bytes, after the still's crop."""
960
+ def panel_source(project, panel: Annotation, index: dict, workdir: Path) -> Path:
961
+ """The picture a panel shows: its still's bytes, after the still's crop.
962
+
963
+ ``index`` is :func:`graph_index` of ``project`` (the panel's still is
964
+ looked up in it) and ``workdir`` is :func:`frames_dir` of ``project``
965
+ (where a cropped still is cached, shared with the render). Raises
966
+ ``ValueError`` when the panel's ``still_id`` is not a still in ``index``
967
+ (or the still records neither an ``artifact_id`` nor a url), and
968
+ ``FileNotFoundError`` when the still's bytes are reachable nowhere — not
969
+ in the catalog, not at the recorded url.
970
+
971
+ The source is not yet the canvas: :func:`panel_canvas` is the one call
972
+ for the prepared picture the render frames on.
973
+ """
955
974
  still = _still_of(panel, index)
956
975
  return _crop_still(
957
976
  _local_path(project, still, "still"),
@@ -962,6 +981,14 @@ def _panel_source(project, panel: Annotation, index: dict, workdir: Path) -> Pat
962
981
  )
963
982
 
964
983
 
984
+ # The pre-#146 private names, which reelee's CURRENT adapter (reelee/_braidio.py)
985
+ # imports. Kept (as the same objects) so that adapter keeps importing; remove once
986
+ # reelee reads the public names (braidio#156).
987
+ _content_keyed_prepare = content_keyed_prepare
988
+ _frames_dir = frames_dir
989
+ _panel_source = panel_source
990
+
991
+
965
992
  def panel_footage(project, panel: Annotation):
966
993
  """The recorded video a footage panel plays (a ``braidio.video.Footage``),
967
994
  or ``None`` for a still panel.
@@ -1013,16 +1040,63 @@ def panel_path(project, panel: Annotation, *, size: tuple[int, int]):
1013
1040
  predates footage keeps working, but the answer describes nothing in the film.
1014
1041
  """
1015
1042
  resolver_identity() # refuses an old burns with the message the render gives
1016
- size = (int(size[0]), int(size[1]))
1043
+ size = _delivery_size(size)
1017
1044
  index = graph_index(project)
1018
1045
  _check_stored_paths([panel], {"size": size}, [_still_of(panel, index)])
1019
- workdir = _frames_dir(project)
1020
- workdir.mkdir(parents=True, exist_ok=True)
1021
- source = _panel_source(project, panel, index, workdir)
1022
- canvas = _content_keyed_prepare(workdir, size)(source, None)
1046
+ source, canvas = _source_and_canvas(project, panel, size=size, index=index)
1023
1047
  return _path_on_canvas(panel.body, canvas, source, aspect=size[0] / size[1])
1024
1048
 
1025
1049
 
1050
+ def panel_canvas(project, panel: Annotation, *, size: tuple[int, int]) -> Path:
1051
+ """The prepared canvas the motion render and :func:`panel_path` frame
1052
+ ``panel`` on at ``size`` — the same file, from the same cache.
1053
+
1054
+ The one call for "what picture does the camera move over?": a preview
1055
+ that draws this file under :func:`panel_path`'s move shows what the film
1056
+ shows. Rebuilding it from :func:`frames_dir`, :func:`panel_source` and
1057
+ :func:`content_keyed_prepare` works today but couples the caller to how
1058
+ the canvas is made; this does not.
1059
+
1060
+ ``size`` is the delivery ``(width, height)`` (a JSON list is fine). Reads
1061
+ the still's bytes and writes the canvas (and any cropped still) into the
1062
+ project's frame cache.
1063
+
1064
+ Unlike :func:`panel_path`, this does **not** check the panel's stored
1065
+ path against ``size``: the canvas does not depend on the path, and a
1066
+ preview may show the picture before a path for this delivery exists.
1067
+
1068
+ Raises ``FileNotFoundError`` when the still's bytes are reachable nowhere
1069
+ (not in the catalog, not at the recorded url), and ``ValueError`` when the
1070
+ panel's ``still_id`` is not a still in the graph.
1071
+
1072
+ A footage panel plays its recording, over no canvas: check
1073
+ :func:`panel_footage` first. For one, this answers with its poster's
1074
+ canvas, which the film never shows.
1075
+ """
1076
+ _, canvas = _source_and_canvas(
1077
+ project, panel, size=_delivery_size(size), index=graph_index(project)
1078
+ )
1079
+ return canvas
1080
+
1081
+
1082
+ def _delivery_size(size) -> tuple[int, int]:
1083
+ """``size`` as the ``(width, height)`` ints the canvas name is keyed on."""
1084
+ return (int(size[0]), int(size[1]))
1085
+
1086
+
1087
+ def _source_and_canvas(
1088
+ project, panel: Annotation, *, size: tuple[int, int], index: dict
1089
+ ) -> tuple[Path, Path]:
1090
+ """``(source, canvas)`` for ``panel`` at ``size``: the cropped still and
1091
+ the prepared canvas over it. The only place a canvas is built outside the
1092
+ render, which builds the same one through ``prepare=``;
1093
+ ``test_panel_canvas_is_the_canvas_the_render_frames_on`` pins that they agree."""
1094
+ workdir = frames_dir(project)
1095
+ workdir.mkdir(parents=True, exist_ok=True)
1096
+ source = panel_source(project, panel, index, workdir)
1097
+ return source, content_keyed_prepare(workdir, size)(source, None)
1098
+
1099
+
1026
1100
  @register_transform(RENDER_NAME)
1027
1101
  class VideoCutRender(BaseTransform):
1028
1102
  """Panels (+ their stills + the episode audio) → ``video-cut/v1`` (motion)."""
@@ -1105,11 +1179,11 @@ class VideoCutRender(BaseTransform):
1105
1179
  fps = int(skel.body["settings"]["fps"])
1106
1180
  aspect = size[0] / size[1]
1107
1181
 
1108
- workdir = _frames_dir(project)
1182
+ workdir = frames_dir(project)
1109
1183
  video_panels = []
1110
1184
  sources: list[Path] = []
1111
1185
  for panel in panels:
1112
- src = _panel_source(project, panel, index, workdir)
1186
+ src = panel_source(project, panel, index, workdir)
1113
1187
  sources.append(src)
1114
1188
  start, end = _interval_s(panel)
1115
1189
  video_panels.append(
@@ -1134,7 +1208,7 @@ class VideoCutRender(BaseTransform):
1134
1208
  size=size,
1135
1209
  fps=fps,
1136
1210
  workdir=workdir,
1137
- prepare=_content_keyed_prepare(workdir, size), # = panel_path's
1211
+ prepare=content_keyed_prepare(workdir, size), # = panel_path's
1138
1212
  path_for=path_for,
1139
1213
  )
1140
1214
  artifact = media_artifact(
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "braidio"
9
- version = "0.0.90"
9
+ version = "0.0.91"
10
10
  description = "Weave narration with extracted media segments into audiovisual productions"
11
11
  readme = "README.md"
12
12
  requires-python = ">=3.10"
@@ -134,3 +134,24 @@ def test_import_braidio_core_does_not_require_graph():
134
134
  # HAS_GRAPH may be True here, but the core API must be importable regardless.
135
135
  for name in ("Script", "WeaveConfig", "render_production", "weave_timeline"):
136
136
  assert hasattr(braidio, name)
137
+
138
+
139
+ def test_every_graph_tier_and_reader_is_public():
140
+ """braidio#146: a host reads the graph through ``braidio.transforms``, never
141
+ a private module. Derived from ``_common``, so a new tier cannot be missed."""
142
+ pytest.importorskip("nw")
143
+ import braidio.transforms as public
144
+ from braidio.transforms import _common, _video_cut
145
+
146
+ tiers = {n for n in vars(_common) if n.startswith("TIER_")}
147
+ readers = {"graph_index", "node_ref"}
148
+ picture = {"content_keyed_prepare", "frames_dir", "panel_source", "panel_canvas"}
149
+ for name in tiers | readers:
150
+ assert getattr(public, name) is getattr(_common, name), name
151
+ for name in picture:
152
+ assert getattr(public, name) is getattr(_video_cut, name), name
153
+ assert (tiers | readers | picture) <= set(public.__all__)
154
+ # reelee's adapter (reelee/_braidio.py) imports these private names until
155
+ # reeleehq/braidio#156: they must stay the very public objects, not copies.
156
+ for private in ("_content_keyed_prepare", "_frames_dir", "_panel_source"):
157
+ assert getattr(_video_cut, private) is getattr(public, private[1:]), private
@@ -2291,6 +2291,56 @@ def test_panel_path_is_the_path_the_render_uses(
2291
2291
  assert panel_path(project, panels[1], size=list(size)) == seen[1]
2292
2292
 
2293
2293
 
2294
+ def test_panel_canvas_is_the_canvas_the_render_frames_on(
2295
+ project, episode, stills, panels, monkeypatch, tmp_path
2296
+ ):
2297
+ """:func:`panel_canvas` is the very file ``video_cut.render`` prepares for
2298
+ each panel (the one :func:`panel_path` resolves its move on), so a preview
2299
+ drawing it under the move shows the film's picture — braidio#146."""
2300
+ pytest.importorskip("burns")
2301
+ PIL = pytest.importorskip("PIL.Image")
2302
+ import braidio.video
2303
+ from braidio.transforms import VIDEO_CUT_RENDER_TRANSFORM, panel_canvas
2304
+
2305
+ np = pytest.importorskip("numpy")
2306
+ tex = np.random.default_rng(5).integers(0, 255, (60, 40, 3), dtype=np.uint8)
2307
+ portrait = tmp_path / "portrait.png"
2308
+ PIL.fromarray(np.kron(tex, np.ones((4, 4, 1), dtype=np.uint8))).save(portrait)
2309
+ cropped = add_still(
2310
+ project,
2311
+ portrait,
2312
+ key="portrait",
2313
+ labelled=False,
2314
+ crop={"x": 0.1, "y": 0.05, "w": 0.8, "h": 0.7},
2315
+ )
2316
+ swapped = _rewrite_in_place(
2317
+ project, panels[1], body={**panels[1].body, "still_id": str(cropped.id)}
2318
+ )
2319
+ panels = [panels[0], swapped, *panels[2:]]
2320
+ prepared = []
2321
+
2322
+ def _render_video(vpanels, *, out_path, size, workdir, prepare, **kw):
2323
+ for i, vp in enumerate(vpanels):
2324
+ prepared.append(
2325
+ Path(prepare(vp.still, Path(workdir) / f"{i}.jpg", size=size))
2326
+ )
2327
+ return _write(out_path, b"MOTION")
2328
+
2329
+ monkeypatch.setattr(braidio.video, "render_video", _render_video)
2330
+ cut = _run(VIDEO_CUT_RENDER_TRANSFORM, project, *panels).annotations[0]
2331
+ size = tuple(cut.body["settings"]["size"])
2332
+ canvases = [panel_canvas(project, p, size=size) for p in panels]
2333
+ assert prepared and canvases == prepared
2334
+ for canvas in canvases:
2335
+ assert canvas.is_file()
2336
+ with PIL.open(canvas) as img:
2337
+ assert img.size == size
2338
+ # JSON callers send the size as a list; the answer is the same file
2339
+ assert panel_canvas(project, panels[1], size=list(size)) == prepared[1]
2340
+ # ... and as floats: the canvas name is keyed on the int size
2341
+ assert panel_canvas(project, panels[1], size=[float(v) for v in size]) == prepared[1]
2342
+
2343
+
2294
2344
  # --- media by content, not by recorded path (thorwhalen/braidio#89) --------------
2295
2345
 
2296
2346
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes