---
sidebar:
  hidden: true
title: roboto.experimental.video.codec
---
Codec seam for the GOP-aware stream decoder.

Isolates the per-codec bitstream knowledge (keyframe detection) and the PyAV decoder name behind one small value type, so [`decoder.decode_stream()`](/docs/reference/python-sdk/roboto/experimental/video/decoder#roboto.experimental.video.decoder.decode_stream) stays codec-agnostic: it depends on a [`VideoCodec`](/docs/reference/python-sdk/roboto/experimental/video/codec#roboto.experimental.video.codec.VideoCodec), never on a specific codec's bitstream format. H.264, H.265, VP9, and AV1 are registered; a new codec adds a [`VideoCodec`](/docs/reference/python-sdk/roboto/experimental/video/codec#roboto.experimental.video.codec.VideoCodec) here plus one `_REGISTRY` entry, with no change to the decoder.

## Module Contents

### AV1

```python
roboto.experimental.video.codec.AV1
```

`from roboto.experimental.video import AV1`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/video/codec.py#L75-L88)

### H264

```python
roboto.experimental.video.codec.H264
```

`from roboto.experimental.video import H264`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/video/codec.py#L54-L59)

### H265

```python
roboto.experimental.video.codec.H265
```

`from roboto.experimental.video import H265`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/video/codec.py#L61-L66)

### VP9

```python
roboto.experimental.video.codec.VP9
```

`from roboto.experimental.video import VP9`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/video/codec.py#L68-L73)

### VideoCodec

```python
class roboto.experimental.video.codec.VideoCodec
```

`from roboto.experimental.video import VideoCodec`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/video/codec.py#L29-L51)

The per-codec hooks the generic stream decoder depends on.

A codec is data plus one function: the PyAV decoder name and a predicate that recognizes an independently decodable keyframe from an encoded frame's bytes. Everything else about decoding (GOP skipping, log-time remapping, error recovery) is codec-agnostic and lives in the decoder.

**Attributes**

- **VideoCodec.decoder_thread_count** (`int | None`) = `None`: Fixed `thread_count` for the decoder context, or `None` for FFmpeg's default.
- **VideoCodec.formats** (`frozenset[str]`): Per-message `format` tokens that resolve to this codec (compared lowercase).
- **VideoCodec.is_keyframe** (`collections.abc.Callable[[bytes], bool]`): Whether an encoded frame is an independently decodable keyframe (clean entry point).
- **VideoCodec.name** (`str`): Canonical codec name (matches the per-message `format` field, lowercase).
- **VideoCodec.pyav_codec_name** (`str`): Decoder name passed to PyAV's `CodecContext.create`.

### resolve_codec()

```python
def roboto.experimental.video.codec.resolve_codec(format: str) -> VideoCodec | None
```

`from roboto.experimental.video import resolve_codec`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/video/codec.py#L94-L105)

Return the codec registered for a per-message `format` token.

**Parameters**

- **format** (`str`): The per-message `format` field of a compressed-video message (e.g. `"h264"`); matched case-insensitively.

**Returns**

- `VideoCodec | None`: The matching [`VideoCodec`](/reference/python-sdk/roboto/experimental/video/codec#roboto.experimental.video.codec.VideoCodec), or `None` when no registered codec claims the token (the stream carries a codec with no decode path).

### supported_formats()

```python
def roboto.experimental.video.codec.supported_formats() -> frozenset[str]
```

`from roboto.experimental.video import supported_formats`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/video/codec.py#L108-L110)

The per-message `format` tokens that have a decode path, lowercase.

**Returns**

- `frozenset[str]`
