# Pipeline

## Input Contract

Expected assets:

- `voice.mp3` or `voice.wav`: the narration track
- `subtitle.srt`: timing track
- `transcript.txt`: authoritative text
- optional `bgm.mp3` or `bgm.wav`

The model should not modify the voice audio. If BGM is used, keep it as a separate `<audio id="bgm">` element and synchronize it to the same timeline.

## Build Steps

1. Parse SRT into cue start/end times.
2. Split transcript into short subtitle phrases and manually correct SRT text errors.
3. Fill `CUES` with `{ s, e, h }`.
4. Build `SCENES` from speech turns, not from equal time slices.
5. Choose shot families from `STYLE.md`.
6. Keep the film data-driven: scene objects feed reusable render functions.
7. Validate the HTML, then preview in a browser and check real audio/subtitle alignment.

## Timing Rules

- The narration audio element is the only master clock.
- `requestAnimationFrame` may redraw every frame, but it must read `audio.currentTime`.
- BGM may be faded in/out, but the fade position must be computed from the same clock.
- Scene start times should be monotonic and normally at least `1.2s` apart.
- For this high-cut visual style, most shots should be `2.5-6s`.

## Recording Rules

- Use fullscreen browser playback.
- Hide all custom controls in the finished file.
- The start overlay is allowed because browsers require a user gesture for audio playback.
- Keep local relative audio paths for reliable recording.
