# gizai:videogen

the LTX-2.5 video model on this computer: its files, its requests (text, pictures, a source video and sound), the stages that make a video, and a worker of it (serveVideos).

```gizlang
import * as Videogen from "gizai:videogen";
```

## Types

### `VideoModel`

```gizlang
type VideoModel = { name: string; gpu: Gpu; ltx: Ref<Option<X.Ltx>>; files: VideoFiles; encoderHost: string; encoderPort: i64; authorization: string; tunings: string; duration: X.DurationHead; ffmpeg: string; }
```

A video model on a GPU: LTX-2.5 22B distilled (gizai:ltx), its text from giz's shared encoder at
encoderHost:encoderPort, or from the text encoder file (port 0).

- `name`: `string`
- `gpu`: `M10.Gpu`
- `ltx`: `Ref<_gizlang_sdk_core.Option<M33.Ltx>>`
- `files`: `M50.VideoFiles`
- `encoderHost`: `string`
- `encoderPort`: `i64`
- `authorization`: `string`
- `tunings`: `string`
- `duration`: `M33.DurationHead`
- `ffmpeg`: `string`

### `VideoFiles`

```gizlang
type VideoFiles = { transformer: string; videoVae: string; audioVae: string; durationHead: string; encoder: string; upsampler: string; fidelity: string; control: string; pose: string; ingredients: string; repaint: string; }
```

LTX-2.5's files: the transformer (INT8 ConvRot), the video VAE, the audio VAE, the duration head, the text
encoder (Gemma 4 12B, INT8 ConvRot), the latent upsampler, the fidelity decoder (the diffusion VAE), the union
control IC-LoRA, DWPose's folder, and the ingredients and in/outpainting IC-LoRAs.

- `transformer`: `string`
- `videoVae`: `string`
- `audioVae`: `string`
- `durationHead`: `string`
- `encoder`: `string`
- `upsampler`: `string`
- `fidelity`: `string`
- `control`: `string`
- `pose`: `string`
- `ingredients`: `string`
- `repaint`: `string`

### `VideoRequest`

```gizlang
type VideoRequest = { prompt: string; width: i64; height: i64; frames: i64; seed: i64; image: Option<Image.Image>; end: Option<Image.Image>; video: string; source: i64; keys: Vec<Image.Image>; at: Vec<i64>; auto: bool; quality: bool; audio: string; fidelity: bool; control: string; controlMode: string; subject: Option<Image.Image>; repaint: string; mask: string; strength: f64; }
```

What is asked of a video model: the `prompt`; `width` x `height` pixels (multiples of 32, at most 1920 x 1088) and
`frames` (8 k + 1, at most 481) at 24 a second; the noise's `seed`; the first frame `image` and the last `end`, or a
`video` (its path) that the new frames extend: its last `source` frames (8 k + 1) at 24 a second open the output;
`strength` (0 to 1) of the first frame, the last, the video's and the injected frames as one-stage guides.

- `prompt`: `string`
- `width`: `i64`
- `height`: `i64`
- `frames`: `i64`
- `seed`: `i64`
- `image`: `_gizlang_sdk_core.Option<gizlang_image.Image>`
- `end`: `_gizlang_sdk_core.Option<gizlang_image.Image>`
- `video`: `string`
- `source`: `i64`
- `keys`: `Vec<gizlang_image.Image>`
- `at`: `Vec<i64>`
- `auto`: `bool`
- `quality`: `bool`
- `audio`: `string`
- `fidelity`: `bool`
- `control`: `string`
- `controlMode`: `string`
- `subject`: `_gizlang_sdk_core.Option<gizlang_image.Image>`
- `repaint`: `string`
- `mask`: `string`
- `strength`: `f64`

## Functions

### `hubVideoFiles`

```gizlang
function hubVideoFiles(hub: Hub.Hub): VideoFiles throws string
```

LTX-2.5's files from the hub (LTX_REPO), the core downloaded first.

Effects: fail, read, write, console, io.

### `videoFiles`

```gizlang
function videoFiles(sys: System, folder: string): VideoFiles throws string
```

LTX-2.5's files in a ComfyUI models folder; the transformer, the VAEs and the duration head must be there.

Effects: fail, read, write, console, io.

### `video`

```gizlang
function video(sys: System, name: string, files: VideoFiles, encoder: string, authorization: string, gpu: Gpu, tunings: string, ffmpeg: string): VideoModel throws string
```

LTX-2.5 (`name`) of `files` on `gpu`, its text from the encoder at `encoder` (HOST:PORT; "": from files.encoder
on the same GPU), the tunings of its kernels saved in the folder `tunings` as they are made, its media read and
written by the program `ffmpeg`.

Effects: fail, read, write, console, io.

### `videoRequestOf`

```gizlang
function videoRequestOf(sys: System, ffmpeg: string, j: JsonValue, seed: i64): VideoRequest throws string
```

The request of a job's input as giz's ltx2-5-distilled sends it: `prompt`, `resolution` ("832x480"), `frames`
(97), `seed`, the uploads `image`, `imageEnd` and `video`, and `injectedFrames` at `injectedFramePositions` ("0, 48,
L": pixel frames, L the last) at `inputVideoStrength` (0 to 1, default 1). Workflows multishot and story are
standard ones (their cuts are in the prompt). Its fixed settings (`steps` 8, `cfg` 1) must be as they are; what this
worker does not do is refused.

Effects: fail, read, write, console, io.

### `videoRequest`

```gizlang
function videoRequest(prompt: string): VideoRequest
```

A request for a video of `prompt`: 832 x 480, 97 frames (4 s at 24 a second), seed 0, fast decoding, no pictures.

### `serveVideos`

```gizlang
function serveVideos(sys: System, name: string, files: VideoFiles, encoder: string, authorization: string, place: Hosting.Place, capacity: i64 = 4): i64 throws string
```

Serves LTX-2.5 (`name`) of `files` as giz's inference worker at `place`, its text from `encoder` (as `video`):
operation video.generate, `capacity` jobs held. It returns when the worker stops.

Effects: fail, read, write, console, io.

## Methods

### `VideoModel.transformer`

```gizlang
function VideoModel.transformer(self: VideoModel, sys: System): X.Ltx throws string
```

The transformer on the GPU, loaded again if a local text encoder took its place.

Effects: fail, read, write, console, io.

### `VideoRequest.describe`

```gizlang
function VideoRequest.describe(self: VideoRequest): string
```

The request in one line for the journal: its size and the features it uses (never its prompt or files).

Effects: fail.

### `VideoModel.repainted`

```gizlang
function VideoModel.repainted(self: VideoModel, sys: System, r: VideoRequest, texts: Vec<Tensor>, progress: (stage: string, step: i64, total: i64) => bool): bytes throws string
```

The repainted video of `r` (giz's IC-LoRA inpainting and outpainting workflows): its source video at width x
height (outpainting: its shorter side to the shorter of width and height, padded gray to the size; inpainting: cut
to the size), the region to paint (the padding, or the mask video's red, widened 30 pixels) painted green; a first
stage at half the size guided by those green frames with the IC-LoRA, its frames blended back over them (Laplacian
pyramid); a second stage of 2 Euler steps from sigma 0.725 on those frames at the full size, blended again. The
source's sound is the voice and the sound of both stages.

Effects: fail, read, write, console, io.

### `VideoModel.make`

```gizlang
function VideoModel.make(self: VideoModel, sys: System, r: VideoRequest, progress: (stage: string, step: i64, total: i64) => bool): bytes throws string
```

The MP4 (H.264 and AAC) of request `r` (videoRequestOf). `progress` is told the stage ("encoding_prompt",
"generating", "encoding_video"), the step done and the steps in all; when it returns false `make` stops with
CANCELLED.

Effects: fail, read, write, console, io.

### `VideoModel.tiles`

```gizlang
function VideoModel.tiles(self: VideoModel, sys: System, r: VideoRequest, latent: Tensor): X.Tiles throws string
```

The decoder `r` asks for (fast or fidelity) over the tiles of `latent`.

Effects: fail, read, write, console, io.

### `VideoModel.clip`

```gizlang
function VideoModel.clip(self: VideoModel, sys: System, width: i64, height: i64, frames: i64, audio: Tensor, next: () => Option<Tensor>): bytes throws string
```

The MP4 of the frames `next` gives a run at a time ([k, 3, H, W] F32 in [0, 1] on the GPU), each run to NVENC as it
comes, and the sound of `audio` (audio latent rows) cut to the frames.

Effects: fail, read, write, console, io.

## Constants

### `LTX`

```gizlang
const LTX = "ltx2-5-distilled"
```

The name giz gives LTX-2.5 22B distilled, the video model.

### `LTX_REPO`

```gizlang
const LTX_REPO = "Lightricks/LTX-2.5"
```

The Hugging Face repository of LTX-2.5's files, in a ComfyUI models folder's layout.

