> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# FrameIterator

> <a href="https://github.com/pixeltable/pixeltable/blob/main/pixeltable/iterators/video.py#L25" id="viewSource" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/View%20Source%20on%20Github-blue?logo=github&labelColor=gray" alt="View Source on GitHub" style={{ display: 'inline', margin: '0px' }} noZoom /></a>

# <span style={{ 'color': 'gray' }}>class</span>  pixeltable.iterators.FrameIterator

Iterator over frames of a video. At most one of `fps`, `num_frames` or `keyframes_only` may be specified. If `fps`
is specified, then frames will be extracted at the specified rate (frames per second). If `num_frames` is specified,
then the exact number of frames will be extracted. If neither is specified, then all frames will be extracted. The
first frame of the video will always be extracted, and the remaining frames will be spaced as evenly as possible.

Args:
fps: Number of frames to extract per second of video. This may be a fractional value, such as 0.5.
If omitted or set to 0.0, or if greater than the native framerate of the video,
then the framerate of the video will be used (all frames will be extracted).
num\_frames: Exact number of frames to extract. The frames will be spaced as evenly as possible. If
`num_frames` is greater than the number of frames in the video, all frames will be extracted.
keyframes\_only: If True, only extract keyframes.
all\_frame\_attrs:
If True, outputs a `pxt.Json` column `frame_attrs` with the following `pyav`-provided attributes
(for more information, see `pyav`'s documentation on
[VideoFrame](https://pyav.org/docs/develop/api/video.html#module-av.video.frame) and
[Frame](https://pyav.org/docs/develop/api/frame.html)):

* `index` (`int`)
* `pts` (`int | None`)
* `dts` (`int | None`)
* `time` (`float | None`)
* `is_corrupt` (`bool`)
* `key_frame` (`bool`)
* `pict_type` (`int`)
* `interlaced_frame` (`bool`)

If False, only outputs frame attributes `frame_idx`, `pos_msec`, and `pos_frame` as separate columns.

## <span style={{ 'color': 'gray' }}>method</span>  close()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
close() -> None
```

Close the iterator and release all resources

## <span style={{ 'color': 'gray' }}>method</span>  create()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
create(**kwargs: Any) -> tuple[type[ComponentIterator], dict[str, Any]]
```

## <span style={{ 'color': 'gray' }}>method</span>  input\_schema()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
input_schema() -> dict[str, pixeltable.type_system.ColumnType]
```

Provide the Pixeltable types of the init() parameters

The keys need to match the names of the init() parameters. This is equivalent to the parameters\_types
parameter of the @function decorator.

## <span style={{ 'color': 'gray' }}>method</span>  output\_schema()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
output_schema(
    *args: Any,
    **kwargs: Any
) -> tuple[dict[str, pixeltable.type_system.ColumnType], list[str]]
```

Specify the dictionary returned by next() and a list of unstored column names

**Returns:**

* `tuple[dict[str, pixeltable.type_system.ColumnType], list[str]]`: a dictionary which is turned into a list of columns in the output table
  a list of unstored column names

## <span style={{ 'color': 'gray' }}>method</span>  set\_pos()

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
set_pos(pos: int) -> None
```

Set the iterator position to pos
