Shot library

Common cinematic shots, coverage and continuity rules built on Shots. Every builder is pure: it takes actor root positions and returns Shot / CoveragePlan models, which apply_shot() or apply_coverage() put into a scene.

from dazpy import shot_library as sl
from dazpy.math3 import Vec3

positions = {"anna": Vec3.from_dict(anna.position), "ben": Vec3.from_dict(ben.position)}
line = sl.LineOfAction.between(positions, "anna", "ben", side=1)

# Master, two-shot, OTS shot/reverse and clean singles, all on one side of the line
plan = sl.dialogue_coverage(line)
assert sl.check_plan(plan, positions) == []      # no camera crosses the 180-degree line
cameras = sl.apply_coverage(scene, plan, subjects=positions)

# Cut a conversation: one OTS per beat, frame ranges, gaze beats, dialogue text
talk = sl.conversation(line, [sl.DialogueBeat("anna", 0, 47, "Where were you?"),
                              sl.DialogueBeat("ben", 48, 95, "Out.")], establish_frames=24)

# Moves and focus
push = sl.push_in(positions, "anna", start=0, end=72, line=line)
ots = sl.with_rack_focus(sl.over_the_shoulder(line, "ben", "anna"), "ben", "anna",
                         start=24, end=48, positions=positions, f_stop=2.0)

The line of action decides which side cameras stand on. Shot/reverse pairs built on one line keep eyelines matched; flipped() gives the other side for a deliberate cross. check_axis() reports a camera (or a move, or an arc) on the wrong side, and check_thirty_degree() a jump cut between near-identical setups.

Shot ids come from shot_name() (OTS_ben_over_anna, SC3_012_CU_anna) and are valid scene-recipe keys. Static shots without distance_cm/anchor_cm convert to recipe cameras; a two-shot of actors standing far apart, or a single with headroom=True, does not.

Common cinematic shots, coverage and continuity rules on top of dazpy.shots.

Every builder here is pure: it takes actor root positions (Vec3, the floor point under a standing figure, as position() reports it) and returns Shot / CoveragePlan models. apply_shot() (or apply_coverage()) puts them into a live scene; pass the same positions mapping as its subjects.

What it covers:

Units are DAZ native: centimetres, Y-up, degrees, timeline frames.

dazpy.shot_library.EYE_HEIGHT_CM = 160.0

Eye height above a standing Genesis-scale actor’s root (cm); the close_up anchor of SHOT_SIZES.

dazpy.shot_library.BODY_WIDTH_CM = 60.0

Width (cm) added to two actors’ separation for their bodies when fitting a two-shot.

dazpy.shot_library.OTS_BACK_CM = 60.0

Over-the-shoulder camera offsets from the foreground actor’s head (cm): behind them (away from the subject), out to the camera side, below eyes.

dazpy.shot_library.SINGLE_OFFSET_DEG = 25.0

How far a clean single swings off the partner’s eyeline toward the camera side.

dazpy.shot_library.DEFAULT_LENSES: Mapping[str, float] = {'establishing': 24.0, 'insert': 100.0, 'master': 35.0, 'move': 50.0, 'ots': 50.0, 'pov': 35.0, 'single': 85.0, 'two_shot': 50.0}

Default lenses per shot family (mm).

dazpy.shot_library.SHOT_ABBREVIATIONS: Mapping[str, str] = {'arc': 'ARC', 'close_up': 'CU', 'establishing': 'EST', 'extreme_close_up': 'ECU', 'extreme_wide': 'EWS', 'full_body': 'FS', 'insert': 'INS', 'master': 'MST', 'medium': 'MS', 'medium_close_up': 'MCU', 'medium_wide': 'MWS', 'move': 'MOVE', 'ots': 'OTS', 'pov': 'POV', 'pull_out': 'PULL', 'push_in': 'PUSH', 'single': 'SGL', 'two_shot': '2S', 'wide': 'WS'}

Shot-id abbreviations, per kind or shot size.

dazpy.shot_library.MOVE_DEFAULTS: Mapping[str, float] = {'crane_down': 100.0, 'crane_up': 100.0, 'dolly_in': 200.0, 'dolly_out': 200.0, 'handheld': 2.0, 'pan_left': 45.0, 'pan_right': 45.0, 'pedestal_down': 50.0, 'pedestal_up': 50.0, 'tilt_down': 20.0, 'tilt_up': 20.0, 'truck_left': 100.0, 'truck_right': 100.0}

Default amount per camera_move() kind (cm, or degrees for pan/tilt).

dazpy.shot_library.COVERAGE_PRESETS: Mapping[str, tuple[tuple[str | None, str, str, float, float], ...]] = {'action': ((None, 'wide', 'eye_level', 0.0, 28.0), (None, 'medium', 'eye_level', 0.0, 50.0), ('three-quarter', 'medium_wide', 'eye_level', -45.0, 35.0), ('hero', 'medium', 'low', 0.0, 35.0)), 'dramatic': ((None, 'wide', 'eye_level', 0.0, 35.0), ('low', 'medium', 'low', 0.0, 50.0), ('high', 'medium', 'high', 0.0, 50.0), ('profile', 'medium_close_up', 'eye_level', 90.0, 85.0)), 'interview': ((None, 'medium', 'eye_level', 0.0, 50.0), ('left', 'medium_close_up', 'eye_level', -30.0, 85.0), ('right', 'medium_close_up', 'eye_level', 30.0, 85.0)), 'standard': ((None, 'wide', 'eye_level', 0.0, 35.0), (None, 'medium', 'eye_level', 0.0, 50.0), (None, 'close_up', 'eye_level', 0.0, 85.0))}

(kind tag, size, angle, azimuth offset deg, lens mm).

Type:

subject_coverage() presets

dazpy.shot_library.shot_name(kind, subject=None, over=None, *, tag=None, scene=None, index=None)[source]

A consistent shot id: [SC<scene>_][<index>_]<ABBR>[_<tag>][_<subject>][_over_<over>].

kind is a key of SHOT_ABBREVIATIONS (a shot kind or size); any other string is used upper-cased. Names are reduced to [A-Za-z0-9-] so the id is a valid scene-recipe key (at most 64 characters).

Examples: shot_name("ots", "bob", over="alice") -> "OTS_bob_over_alice"; shot_name("close_up", "anna", scene=3, index=12) -> "SC3_012_CU_anna".

class dazpy.shot_library.LineOfAction(a, b, a_pos, b_pos, side=1)[source]

Bases: object

The 180-degree line between actors a and b, and the side cameras keep to.

Parameters:
  • a (str) – Actor keys.

  • b (str) – Actor keys.

  • a_pos (Vec3) – Their root positions (only X/Z matter).

  • b_pos (Vec3) – Their root positions (only X/Z matter).

  • side (int) – +1 or -1 – which half-plane the cameras stand in. +1 is to a’s right as a faces b (+X when a->*b* runs along -Z).

a: str
b: str
a_pos: Vec3
b_pos: Vec3
side: int = 1
classmethod between(positions, a, b, side=1)[source]

The line between keys a and b of positions.

property direction: Vec3

Unit horizontal direction from a to b.

property normal: Vec3

Unit horizontal direction from the line toward the camera side.

property midpoint: Vec3
property separation: float
flipped()[source]

The same line with cameras on the other side (a deliberate cross).

position(key)[source]
other(key)[source]
side_of(point, tolerance_cm=1.0)[source]

+1 / -1 for the half-plane point is in, 0 within tolerance_cm of the line.

dazpy.shot_library.headroom_anchor(size, eye_height=160.0)[source]

Aim height (cm above the root) that puts a standing actor’s eyes on the upper third.

Pass it as anchor_cm. The frame height at a size’s fitted distance is its SHOT_SIZES fit height, so the eyes sit a sixth of that above the frame centre.

dazpy.shot_library.lead_room(camera_position, aim, facing, threshold=0.15)[source]

The COMPOSITIONS value that leaves room in front of a gaze.

A subject looking screen-right goes on the left third and vice versa; one looking (nearly) into or away from the lens stays centred.

Parameters:
  • camera_position (Vec3) – The camera pose.

  • aim (Vec3) – The camera pose.

  • facing (Vec3) – Direction the subject looks (any length; only X/Z matter).

  • threshold (float) – Minimum sideways component (of the unit facing) for an off-centre composition.

dazpy.shot_library.THIRD_X = 0.3333333333333333

Horizontal screen positions (-1 = left edge, +1 = right edge) of the rule-of-thirds and golden-section verticals.

dazpy.shot_library.compose_aim(position, target, screen_x, focal_length, *, frame_width_mm=36.0, aspect=0.75)[source]

The aim point that puts target at horizontal screen position screen_x.

screen_x runs from -1 (left edge) to +1 (right edge); 0 is centred, THIRD_X the right third, GOLDEN_X the right golden section. The camera turns, it does not move. frame_width_mm spans the frame height (as in Studio), so the width is that / aspect (height / width).

dazpy.shot_library.establishing(line, *, size='extreme_wide', elevation_deg=10.0, lens=None, id=None, frame_range=None, frame_width_mm=36.0, aspect=0.75)[source]

A wide, slightly high shot of both actors from the camera side of the line.

dazpy.shot_library.master(line, *, size='wide', lens=None, id=None, frame_range=None, frame_width_mm=36.0, aspect=0.75)[source]

The master: both actors, perpendicular to the line, at eye level.

dazpy.shot_library.two_shot(line, *, size='medium_wide', lens=None, id=None, frame_range=None, frame_width_mm=36.0, aspect=0.75)[source]

A two-shot: both actors at size (widened if they stand too far apart to fit).

dazpy.shot_library.single(line, subject, *, size='medium_close_up', lens=None, offset_deg=25.0, angle='eye_level', headroom=False, lead=True, id=None, frame_range=None)[source]

A clean single of subject, from near their partner’s eyeline on the camera side.

Parameters:
  • line (LineOfAction) – The line of action; subject must be on it.

  • size (str) – Shot size.

  • offset_deg (float) – How far the camera swings off the partner’s eyeline toward the camera side (0 = straight down the eyeline).

  • angle (str) – Named camera angle.

  • headroom (bool) – Aim with headroom_anchor() (eyes on the upper third).

  • lead (bool) – Compose with lead_room() toward the partner.

dazpy.shot_library.over_the_shoulder(line, foreground, subject, *, lens=None, back_cm=60.0, side_cm=35.0, drop_cm=10.0, eye_height=160.0, compose=True, frame_width_mm=36.0, aspect=0.75, id=None, frame_range=None)[source]

Over foreground’s shoulder onto subject, from the camera side of the line.

The camera stands back_cm behind the foreground actor’s head and side_cm out toward the camera side, a little below eye level. With compose, the subject’s eyes land on the third of the frame opposite the foreground shoulder.

dazpy.shot_library.shot_reverse_shot(line, *, lens=None, frame_ranges=None, **ots_kw)[source]

The OTS pair: onto b over a, and the reverse onto a over b, both on the line’s side.

dazpy.shot_library.pov(positions, viewer, target, *, lens=None, eye_height=160.0, forward_cm=10.0, id=None, frame_range=None)[source]

viewer’s point of view: from their eyes toward target (an actor key’s eyes, or a point).

dazpy.shot_library.insert(point, *, size='extreme_close_up', azimuth_deg=0.0, elevation_deg=30.0, line=None, lens=None, name='detail', id=None, frame_range=None)[source]

An insert: a tight shot of a detail at point (a prop, a hand), looking down at it.

With line, the camera azimuth comes from the line’s camera side (keeping the insert on the same side as the coverage) instead of azimuth_deg.

dazpy.shot_library.euler_from_quaternion(q)[source]

Camera Euler (x, y, z) degrees for Studio’s world rotation quaternion.

q holds DzQuat components: the {"x", "y", "z", "w"} dict rotation returns, or a Quat built from it. DzQuat’s (x, y, z) are the negation (conjugate) of Quat.from_euler’s for the same rotation (live-verified), so they are conjugated here. The result is in canonical_rotation() form.

dazpy.shot_library.canonical_rotation(rotation)[source]

The equivalent camera Euler with pitch (x) in [-90, 90].

aimAt can leave a camera at e.g. (-177, 73, 180), which faces the same way as (3, 107, 0); adding a pan to the first form turns the wrong way. Uses the identity (x, y, z) == (x + 180, 180 - y, z + 180).

dazpy.shot_library.forward_from_rotation(rotation)[source]

Unit view direction of a camera with Euler rotation (the inverse of look_at_euler).

A Studio camera’s (x, y, z) rotation channels compose as Quat.from_euler(x, y, z, "ZYX") (live-verified, roll included).

dazpy.shot_library.look_rotation(position, aim, roll_deg=0.0)[source]

Camera Euler (x, y, z) that looks from position at aim, rolled roll_deg about the view axis – a dutch angle. Positive roll tips the camera’s top toward screen-left (camera_up()), as Studio’s own ZRotate does on an unturned camera.

Use it as rotation when a shot needs roll, which look_at aiming can’t express.

dazpy.shot_library.camera_up(rotation)[source]

Unit up direction (screen top) of a camera with Euler rotation.

dazpy.shot_library.aim_from_rotation(position, rotation, distance=100.0)[source]

The point distance ahead of a camera at position with rotation.

dazpy.shot_library.camera_move(kind, position, rotation, *, start, end, amount=None, lens=None, id=None, seed=0, step=3)[source]

A camera move from the pose (position, rotation), keyed at start and end.

rotation is Euler degrees, or Studio’s world quaternion (rotation’s dict; see euler_from_quaternion()).

Kinds (see MOVE_DEFAULTS for each default amount):

  • dolly_in / dolly_out – along the horizontal view direction (cm).

  • truck_left / truck_right – sideways (cm).

  • pedestal_up / pedestal_down, crane_up / crane_down – vertically (cm); a crane is a bigger pedestal by default.

  • pan_left / pan_right – yaw (degrees); tilt_up / tilt_down – pitch.

  • handheld – seeded, repeatable jitter every step frames; amount is the position amplitude (cm), rotation jitter is half that in degrees.

Every keyframe carries an explicit rotation, so the move never re-aims; rotation is first put in canonical_rotation() form.

dazpy.shot_library.push_in(positions, subject, *, start, end, from_size='wide', to_size='close_up', azimuth_deg=0.0, line=None, lens=None, id=None, frame_width_mm=36.0, aspect=0.75)[source]

A dolly from from_size to to_size on subject, re-aiming as the frame tightens.

The camera direction is azimuth_deg, or a clean-single angle when a line is given (subject must be on it).

dazpy.shot_library.pull_out(positions, subject, *, start, end, from_size='close_up', to_size='wide', **kw)[source]

push_in() in reverse: from from_size back out to to_size.

dazpy.shot_library.arc(subject, *, start, end, radius=250.0, start_azimuth_deg=0.0, end_azimuth_deg=360.0, elevation_deg=10.0, target_offset_cm=130.0, lens=None, id=None, step_deg=None, positions=None)[source]

An arc (orbit) around actor subject.

By default it is an Orbit, baked one placement per frame by apply_shot() (exact, but a few calls per frame). With step_deg it is a Keyframed move with a waypoint every step_deg degrees (and at both ends) that Studio interpolates – far cheaper for long shots; needs positions.

An arc that sweeps across the line of action crosses it on purpose; check_axis() reports it.

dazpy.shot_library.CIRCLE_OF_CONFUSION_MM = 0.03

Circle of confusion (mm) for a 36 mm-wide frame – the usual full-frame value.

dazpy.shot_library.depth_of_field_limits(focal_length, f_stop, focal_distance, *, coc_mm=0.03)[source]

(near, far) limits of acceptable sharpness (cm) for a lens focused at focal_distance (cm).

Thin-lens hyperfocal approximation; far is None (infinity) at or beyond the hyperfocal distance.

dazpy.shot_library.focus_point(target, positions=None, eye_height=160.0)[source]

Where to focus on target: an actor key’s eyes, or a point as given.

dazpy.shot_library.rack_focus(camera_position, from_target, to_target, *, start, end, positions=None, hold_from=0, hold_to=0, eye_height=160.0)[source]

A rack focus from from_target to to_target between start and end.

Targets are actor keys (focus on the eyes), points, or focal distances (cm). The pull runs from start + hold_from to end - hold_to; a hold that leaves no time to pull is dropped.

dazpy.shot_library.camera_position(shot, positions=None, *, frame_width_mm=36.0, aspect=0.75)[source]

Where shot’s camera stands (its first position, for a move).

dazpy.shot_library.camera_positions(shot, positions=None, *, frame_width_mm=36.0, aspect=0.75, orbit_step_deg=10.0)[source]

Every position shot’s camera passes through: one for a static shot, each waypoint of a Keyframed move, samples along an Orbit.

dazpy.shot_library.with_rack_focus(shot, from_target, to_target, *, start, end, positions=None, f_stop=None, **kw)[source]

shot with a rack_focus() measured from its camera position, depth of field on.

class dazpy.shot_library.ContinuityIssue(kind, shot_id, message, other_shot_id=None)[source]

Bases: object

A continuity problem: kind is "axis" (a camera crosses the line of action) or "thirty_degree" (a jump cut between near-identical setups).

kind: str
shot_id: str
message: str
other_shot_id: str | None = None
dazpy.shot_library.check_axis(shots, line, positions=None, *, tolerance_cm=1.0, frame_width_mm=36.0, aspect=0.75)[source]

Shots whose camera stands (or moves) on the wrong side of line.

A camera on the line itself (a neutral shot) is allowed.

dazpy.shot_library.check_thirty_degree(shots, positions=None, *, min_angle_deg=30.0, same_subject_cm=50.0, size_ratio=1.33, frame_width_mm=36.0, aspect=0.75)[source]

Consecutive static shots (in cut order) of the same subject whose camera angle changes by less than min_angle_deg without a clear size change – a jump cut.

Two setups count as the same subject when their aim points are within same_subject_cm, and as the same size when their camera distances differ by less than a factor of size_ratio.

dazpy.shot_library.check_continuity(shots, positions=None, *, line=None, **kw)[source]

check_axis() (when line is given) plus check_thirty_degree(), in cut order.

dazpy.shot_library.plan_line(plan, positions, *, frame_width_mm=36.0, aspect=0.75)[source]

The plan’s line of action, its side taken from the first shot that is off the line.

dazpy.shot_library.check_plan(plan, positions, **kw)[source]

check_continuity() for every sequence of plan, against the plan’s axis.

dazpy.shot_library.subject_coverage(subject, *, preset='standard', azimuth_deg=0.0, plan_id=None, headroom=False)[source]

Single-actor coverage from COVERAGE_PRESETS, around azimuth_deg (0 = the actor’s +Z side).

dazpy.shot_library.dialogue_coverage(line, *, plan_id=None, include=('master', 'two_shot', 'ots', 'singles'), single_size='close_up', **kw)[source]

Standard two-actor coverage on one side of line: master, two-shot, the OTS shot/reverse pair and the clean singles (pick with include).

kw (frame_width_mm, aspect) goes to the framing builders.

class dazpy.shot_library.DialogueBeat(speaker, start, end, line=None)[source]

Bases: object

speaker talks from frame start to end (inclusive); line is the dialogue text.

speaker: str
start: int
end: int
line: str | None = None
dazpy.shot_library.conversation(line, beats, *, plan_id='conversation', style='ots', establish_frames=0, single_size='medium_close_up', lens=None, **kw)[source]

Cut a conversation between the line’s two actors, one shot per beat.

Each beat is covered on the speaker – over the listener’s shoulder (style="ots") or in a clean single (style="singles") – from the same side of the line, so eyelines match across the cuts. Every shot carries its frame range, gaze beats (speaker and listener look at each other) and the dialogue as storyboard text.

Parameters:
  • establish_frames (int) – When > 0, open on a master for this many frames at the start of the first beat (which then starts after it).

  • kw (Any) – frame_width_mm / aspect for the framing builders.

dazpy.shot_library.apply_coverage(scene, plan, *, subjects=None, cameras=None, frame_width_mm=36.0, aspect=0.75)[source]

Apply every shot of plan on its own camera, named and labelled after the shot id.

Parameters:
  • cameras (Mapping[str, DazCamera] | None) – Existing cameras to reuse, by shot id; others are created.

  • subjects (Mapping[str, Any] | None) – As for apply_shot() – usually the same positions mapping the shots were built from.

Returns:

{shot id: camera} in plan order.

Return type:

dict[str, DazCamera]