Skip to content

API Reference parrot.clients.google.reel.timeline

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.clients.google.reel.timeline

View source

Pure scene-timeline planning and duration checks (FEAT-564, spec module M6).

Every function here is pure computation — no MoviePy, no provider calls, no I/O. plan_timeline produces one explicit :class:TimelinePlan that the assembly stage (a later task) consumes as its sole source of truth for clip placement; nothing here loops, stretches or regenerates a short clip — :func:check_measured_duration only ever raises.

Alias ReelError

Re-exported from parrot.clients.google.reel.errors.ReelError.

Alias ReelErrorCode

Re-exported from parrot.clients.google.reel.errors.ReelErrorCode.

Alias ReelValidationError

Re-exported from parrot.clients.google.reel.errors.ReelValidationError.

Class TimelineEntry

One scene's generated clip, as input to timeline planning.

Fields:

Field Type Default Description
scene_index int Original scene index, preserved even under skip.
clip_path Path Local path to the scene's generated clip.
edit_seconds float The scene's edit target duration (timeline slot length).
narration_path Optional[Path] Optional narration audio path for this scene.

Class TimelinePlan

The one explicit plan assembly consumes for clip placement.

Fields:

Field Type Default Description
transition Literal['cut', 'crossfade']
fps float
segments List[TimelineSegment]
final_duration_seconds float

Class TimelineSegment

One entry's placement within the final assembled timeline.

Fields:

Field Type Default Description
scene_index int
clip_path Path
start_seconds float
edit_seconds float
narration_path Optional[Path] None
overlap_with_next_seconds float

Function check_measured_duration

Verifies a measured clip is not shorter than its target by more than one frame.

Never loops, stretches or regenerates a short clip — this function only ever raises or silently passes.

check_measured_duration(target: float, measured: float, fps: float) -> None

Parameter Type Default Description
target float The scene's edit target duration in seconds.
measured float The clip's actually-measured duration in seconds.
fps float The output frame rate, used to compute the one-frame tolerance.

Raises:

  • ReelValidationError — Non-finite/non-positive fps.
  • ReelError — insufficient_duration when measured is shorter than target by more than one output frame (1.0 / fps seconds).

Function check_narration_fits

Verifies narration audio fits within its scene's edit target.

Shorter narration is left as-is (padded with silence elsewhere, never time-stretched) — this function only rejects narration that is too long.

check_narration_fits(target: float, narration_seconds: float) -> None

Parameter Type Default Description
target float The scene's edit target duration in seconds.
narration_seconds float The narration audio's duration in seconds.

Raises:

  • ReelError — narration_too_long when narration_seconds exceeds target.

Function plan_timeline

Computes the final assembled timeline for a sequence of scene clips.

Cuts: the final duration is the sum of every entry's edit_seconds. Crossfades: the final duration subtracts every ACTUAL consumed overlap (crossfade_seconds between each adjacent pair) — four 5 s scenes give 20 s with cuts, or 18.5 s with three 0.5 s crossfades.

plan_timeline(entries: Sequence[TimelineEntry], *, transition: Literal['cut', 'crossfade'], crossfade_seconds: float = _DEFAULT_CROSSFADE_SECONDS, fps: float) -> TimelinePlan

Parameter Type Default Description
entries Sequence[TimelineEntry] Ordered scene clips to place on the timeline. Original scene indices are preserved on the output segments.
transition Literal['cut', 'crossfade'] "cut" (no overlap) or "crossfade".
crossfade_seconds float _DEFAULT_CROSSFADE_SECONDS The overlap duration between adjacent segments, only used when transition == "crossfade".
fps float The output frame rate this plan is computed for.

Returns: TimelinePlan — The computed :class:TimelinePlan.

Raises:

  • ReelValidationError — Non-finite/non-positive fps, an empty entries sequence, a non-finite/non-positive edit_seconds on any entry, a non-finite/negative crossfade_seconds, or a crossfade overlap that is not strictly shorter than BOTH of its neighboring segments' durations (an overlap consuming an entire scene, or more, leaves no content for that scene to show).

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally