fix(hooks): ground GENERAL stretches too when the video is a screencast
First prod run of hook grounding on a product-update video: the layout picker said screencast (0.95) but the render emitted only track/general ranges, because the width gate did not upgrade the stats cards, so the grounding never fired and every clip kept its topic-summary hook. A GENERAL scene on a screencast video is a face-less full-screen slide or dialog, not a group shot (checked frame by frame), so it now counts as screen when screencast_layout is enabled for the job. Claude-Session: https://claude.ai/code/session_014i9z6mLTy978uRCfSsMfBq
This commit is contained in:
parent
58056996f4
commit
41952d6208
3 changed files with 34 additions and 4 deletions
|
|
@ -126,7 +126,9 @@ The hook and title come from the detail pass, which only reads the
|
|||
transcript, so on a clip whose meaning is on the screen (a settings dialog,
|
||||
a spreadsheet) they summarise the video's topic instead of naming what is
|
||||
shown. After the render, if the `<clip>.layout.json` sidecar says at least
|
||||
25% of the clip is `screencast` / `wide` / `inset`, three frames from those
|
||||
25% of the clip is `screencast` / `wide` / `inset` (plus `general` when the
|
||||
layout picker called the video a screencast: a face-less scene there is a
|
||||
slide or a dialog, not a group shot), three frames from those
|
||||
stretches at 1024px plus the clip's own words go to Gemini
|
||||
(`GroundedHook`) and `viral_hook_text` / `video_title_for_youtube_short`
|
||||
are rewritten in place before `auto_hook_clip` burns them; the originals
|
||||
|
|
|
|||
|
|
@ -35,11 +35,27 @@ def enabled() -> bool:
|
|||
return os.environ.get("HOOK_GROUNDING", "1").strip() != "0"
|
||||
|
||||
|
||||
def screen_ranges(ranges):
|
||||
def screen_video() -> bool:
|
||||
"""True when the layout picker (or the user) called this source a
|
||||
screencast. On such a video a GENERAL stretch, which the scene classifier
|
||||
emits for "no face in frame", is a full-screen slide, dialog or terminal
|
||||
(verified on a product update video: every GENERAL scene was a stats
|
||||
card), even when the width gate did not upgrade it to SCREENCAST."""
|
||||
try:
|
||||
import screencast_layout
|
||||
return bool(getattr(screencast_layout, "ENABLED", False))
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
def screen_ranges(ranges, on_screen_video=None):
|
||||
"""(start, end) pairs, clip seconds, of the stretches rendered on-screen."""
|
||||
import layout_ranges
|
||||
layouts = set(SCREEN_LAYOUTS)
|
||||
if screen_video() if on_screen_video is None else on_screen_video:
|
||||
layouts.add("general")
|
||||
return [(r["start"], r["end"]) for r in layout_ranges.normalise(ranges)
|
||||
if r["layout"] in SCREEN_LAYOUTS]
|
||||
if r["layout"] in layouts]
|
||||
|
||||
|
||||
def wanted(ranges, clip_duration) -> bool:
|
||||
|
|
|
|||
|
|
@ -19,13 +19,25 @@ MIXED = [{"start": 0, "end": 5, "layout": "track"},
|
|||
|
||||
# --- when to run -----------------------------------------------------------
|
||||
|
||||
def test_screen_layouts_trigger_and_face_layouts_do_not():
|
||||
def test_screen_layouts_trigger_and_face_layouts_do_not(monkeypatch):
|
||||
monkeypatch.setattr(hg, "screen_video", lambda: False)
|
||||
assert hg.wanted(SCREEN, 30) is True
|
||||
assert hg.wanted(MIXED, 30) is True
|
||||
assert hg.wanted(FACE, 30) is False
|
||||
assert hg.wanted([], 30) is False
|
||||
|
||||
|
||||
def test_general_counts_as_screen_only_on_a_screencast_video(monkeypatch):
|
||||
# The reported case: picker said screencast, the render emitted
|
||||
# track/general only (stats cards have no face), grounding never ran.
|
||||
general = [{"start": 0, "end": 8, "layout": "track"},
|
||||
{"start": 8, "end": 30, "layout": "general"}]
|
||||
monkeypatch.setattr(hg, "screen_video", lambda: True)
|
||||
assert hg.wanted(general, 30) is True
|
||||
monkeypatch.setattr(hg, "screen_video", lambda: False)
|
||||
assert hg.wanted(general, 30) is False # a group shot is not a screen
|
||||
|
||||
|
||||
def test_a_blip_is_not_enough(monkeypatch):
|
||||
blip = [{"start": 0, "end": 2, "layout": "screencast"},
|
||||
{"start": 2, "end": 30, "layout": "track"}]
|
||||
|
|
|
|||
Loading…
Reference in a new issue