> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/curator/llms.txt.
> For full documentation content, see https://docs.nvidia.com/nemo/curator/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/curator/_mcp/server.

# nemo_curator.utils.nvcodec_utils

## Module Contents

### Classes

| Name                                                                               | Description                                                                                |
| ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| [`FrameExtractionPolicy`](#nemo_curator-utils-nvcodec_utils-FrameExtractionPolicy) | Policy for extracting frames from video, supporting full extraction or FPS-based sampling. |
| [`NvVideoDecoder`](#nemo_curator-utils-nvcodec_utils-NvVideoDecoder)               | Low-level NVIDIA hardware-accelerated video decoder.                                       |
| [`PyNvcFrameExtractor`](#nemo_curator-utils-nvcodec_utils-PyNvcFrameExtractor)     | High-level frame extraction interface using PyNvVideoCodec.                                |
| [`VideoBatchDecoder`](#nemo_curator-utils-nvcodec_utils-VideoBatchDecoder)         | GPU-accelerated video decoder that processes video frames in batches.                      |

### Functions

| Name                                                                                     | Description                                               |
| ---------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| [`gpu_decode_for_stitching`](#nemo_curator-utils-nvcodec_utils-gpu_decode_for_stitching) | Decode video frames for stitching using GPU acceleration. |

### Data

[`_PYNVC_AVAILABLE`](#nemo_curator-utils-nvcodec_utils-_PYNVC_AVAILABLE)

[`pixel_format_to_cvcuda_code`](#nemo_curator-utils-nvcodec_utils-pixel_format_to_cvcuda_code)

### API

```python
class nemo_curator.utils.nvcodec_utils.FrameExtractionPolicy
```

**Bases:** `enum.Enum`

Policy for extracting frames from video, supporting full extraction or FPS-based sampling.

This enum defines the available strategies for frame extraction from video content.

```python
class nemo_curator.utils.nvcodec_utils.NvVideoDecoder(
    enc_file: str,
    device_id: int,
    batch_size: int,
    cuda_ctx: typing.Any,
    cvcuda_stream: typing.Any
)
```

Low-level NVIDIA hardware-accelerated video decoder.

This class provides direct access to NVIDIA's hardware video decoding capabilities,
handling frame decoding and memory management for video processing pipelines.

```python
nemo_curator.utils.nvcodec_utils.NvVideoDecoder.generate_decoded_frames() -> list[torch.Tensor]
```

Generate decoded frames from the video.

**Returns:** `list[torch.Tensor]`

List of decoded frames as tensors.

```python
nemo_curator.utils.nvcodec_utils.NvVideoDecoder.get_next_frames() -> torch.Tensor | None
```

Get the next frames from the video.

**Returns:** `torch.Tensor | None`

Next frames from the video as a tensor.

```python
class nemo_curator.utils.nvcodec_utils.PyNvcFrameExtractor(
    width: int,
    height: int,
    batch_size: int
)
```

High-level frame extraction interface using PyNvVideoCodec.

This class provides a simplified interface for extracting frames from videos using
hardware acceleration, supporting both full extraction and FPS-based sampling.

```python
nemo_curator.utils.nvcodec_utils.PyNvcFrameExtractor.__call__(
    input_path: pathlib.Path,
    extraction_policy: nemo_curator.utils.nvcodec_utils.FrameExtractionPolicy = FrameExtractionPolicy.full,
    sampling_fps: int = 1
) -> torch.Tensor
```

Extract frames from the video.

**Parameters:**

Path to the video file to process.

Policy for extracting frames.

Sampling rate for FPS-based extraction.

**Returns:** `torch.Tensor`

List of decoded frames as tensors.

```python
class nemo_curator.utils.nvcodec_utils.VideoBatchDecoder(
    batch_size: int,
    target_width: int,
    target_height: int,
    device_id: int,
    cuda_ctx: str,
    cvcuda_stream: str
)
```

GPU-accelerated video decoder that processes video frames in batches.

This class handles video decoding using NVIDIA hardware acceleration, supporting
batch processing of frames with color space conversion and resizing capabilities.

```python
nemo_curator.utils.nvcodec_utils.VideoBatchDecoder.__call__(
    input_path: str
) -> torch.Tensor | None
```

Process video frames in batches using GPU acceleration.

**Parameters:**

Path to the video file to process.

**Returns:** `torch.Tensor | None`

Processed video frames as a tensor.

```python
nemo_curator.utils.nvcodec_utils.VideoBatchDecoder.get_fps() -> int | None
```

Get the frame rate of the video.

**Returns:** `int | None`

Frame rate of the video.

```python
nemo_curator.utils.nvcodec_utils.gpu_decode_for_stitching(
    device_id: int,
    ctx: str,
    stream: int,
    input_path: pathlib.Path,
    frame_list: list[int],
    batch_size: int = 1
) -> list[torch.Tensor]
```

Decode video frames for stitching using GPU acceleration.

**Parameters:**

GPU device ID.

CUDA context.

CUDA stream.

Path to the video file to process.

List of frame indices to decode.

Number of frames to process in each batch.

**Returns:** `list[torch.Tensor]`

List of decoded frames as tensors.

```python
nemo_curator.utils.nvcodec_utils._PYNVC_AVAILABLE = True
```

```python
nemo_curator.utils.nvcodec_utils.pixel_format_to_cvcuda_code = {Nvc.Pixel_Format.YUV444: cvcuda.ColorConversion.YUV2RGB, Nvc.Pixel_Format.NV12:...
```