stages.video.clipping.video_frame_extraction#

Module Contents#

Classes#

VideoFrameExtractionStage

Stage that extracts frames from videos into numpy arrays.

Functions#

get_frames_from_ffmpeg

Fetch resized frames for video.

API#

class stages.video.clipping.video_frame_extraction.VideoFrameExtractionStage#

Bases: nemo_curator.stages.base.ProcessingStage[nemo_curator.tasks.video.VideoTask, nemo_curator.tasks.video.VideoTask]

Stage that extracts frames from videos into numpy arrays.

This stage handles video frame extraction using either FFmpeg (CPU/GPU) or PyNvCodec, converting video content into standardized frame arrays for downstream processing.

decoder_mode: str#

‘pynvc’

inputs() tuple[list[str], list[str]]#

Define stage input requirements.

Returns (tuple[list[str], list[str]]): Tuple of (required_attributes, required_columns) where: - required_top_level_attributes: List of task attributes that must be present - required_data_attributes: List of attributes within the data that must be present

name: str#

‘video_frame_extraction’

output_hw: tuple[int, int]#

(27, 48)

outputs() tuple[list[str], list[str]]#

Define stage output specification.

Returns (tuple[list[str], list[str]]): Tuple of (output_attributes, output_columns) where: - output_top_level_attributes: List of task attributes this stage adds/modifies - output_data_attributes: List of attributes within the data that this stage adds/modifies

process(
task: nemo_curator.tasks.video.VideoTask,
) nemo_curator.tasks.video.VideoTask#

Process a task and return the result. Args: task (X): Input task to process Returns (Y | list[Y]): - Single task: For 1-to-1 transformations - List of tasks: For 1-to-many transformations (e.g., readers) - None: If the task should be filtered out

pyncv_batch_size: int#

64

setup(
worker_metadata: nemo_curator.backends.base.WorkerMetadata | None = None,
) None#

Setup method called once before processing begins. Override this method to perform any initialization that should happen once per worker. Args: worker_metadata (WorkerMetadata, optional): Information about the worker (provided by some backends)

verbose: bool#

False

stages.video.clipping.video_frame_extraction.get_frames_from_ffmpeg(
video_file: pathlib.Path,
width: int,
height: int,
*,
use_gpu: bool = False,
) numpy.typing.NDArray[numpy.uint8] | None#

Fetch resized frames for video.