# gizai:video/frames

H.264 tracks of frame tensors (NVENC, or x264 through ffmpeg on other GPUs).

```gizlang
import * as Frames from "gizai:video/frames";
```

## Types

### `H264`

```gizlang
type H264 = { sys: System; gpu: Gpu; ffmpeg: string; width: i64; height: i64; fps: i64; quality: i64; kernel: u64; encoders: Vec<Encoder>; raw: bytes; n: i64; baseline?: bool; }
```

An H.264 track that takes its frames a part at a time, as `h264` encodes them: on NVENC or libva as each part
comes, or, without either, as NV12 bytes that libx264 encodes at `close`.

- `sys`: `gizlang_system.System`
- `gpu`: `M10.Gpu`
- `ffmpeg`: `string`
- `width`: `i64`
- `height`: `i64`
- `fps`: `i64`
- `quality`: `i64`
- `kernel`: `u64`
- `encoders`: `Vec<M6.Encoder>`
- `raw`: `bytes`
- `n`: `i64`
- `baseline`: `_gizlang_sdk_core.Option<bool>`

## Functions

### `h264`

```gizlang
function h264(sys: System, frames: Tensor, fps: i64, quality: i64, ffmpeg: string = FFMPEG, baseline: bool = false): Track throws string
```

The H.264 track of `frames` ([3, n, height, width] RGB in [0, 1], f32 on a GPU; height and width even) at `fps`
frames a second: High profile, P frames only, a key frame each 250 frames, at constant quality `quality` (0 to 51,
lower is better; 22 gives 39 dB and 1.5 MB on 5 s of H3's 480p video). On NVIDIA NVENC encodes (about 2 ms a frame),
on AMD libva; on another GPU (Apple's), and where neither opens (rented containers that hide the encoder),
`ffmpeg` (its name on PATH, or a path) does, with libx264.

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

### `h264Writer`

```gizlang
function h264Writer(sys: System, gpu: Gpu, width: i64, height: i64, fps: i64, quality: i64, ffmpeg: string = FFMPEG, baseline: bool = false): H264 throws string
```

A writer of width x height frames (even) at `fps` and `quality`, on `gpu`.

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

### `rgbaKernel`

```gizlang
function rgbaKernel(): Kernel
```

Frame `f` of planar RGB [3, n, h, w] in [0, 1] to an RGBA image (4 bytes a pixel, rows of 4 w bytes, alpha 255).

Effects: fail.

## Methods

### `H264.push`

```gizlang
function H264.push(self: mut H264, frames: Tensor): void throws string
```

The frames ([3, n, height, width] RGB in [0, 1], f32 on the writer's GPU), after those pushed before.

Effects: fail, read, write, io.

### `H264.close`

```gizlang
function H264.close(self: mut H264): Track throws string
```

The track of the frames pushed.

Effects: fail, read, write, io.

## Constants

### `FFMPEG`

```gizlang
const FFMPEG = "ffmpeg"
```

The program that reads and writes media where a caller names none: ffmpeg on PATH (ffprobe beside it).

