nemo_curator.stages.video.io.video_reader
nemo_curator.stages.video.io.video_reader
Module Contents
Classes
API
Bases: CompositeStage[_EmptyTask, VideoTask]
Composite stage that reads video files from storage and downloads/processes them.
This stage combines FilePartitioningStage and VideoReaderStage into a single high-level operation for reading video files from a directory and processing them with metadata extraction.
Parameters:
Path to the directory containing video files
Maximum number of videos to process (None for unlimited)
Whether to enable verbose logging during download/processing
Initialize the parent CompositeStage after dataclass initialization.
Decompose into constituent execution stages.
Returns: list[ProcessingStage]
List of processing stages: [FilePartitioningStage, VideoReaderStage]
Get a description of what this composite stage does.
Bases: ProcessingStage[FileGroupTask, VideoTask]
Stage that reads video files from local filesystem and extracts metadata.
This stage processes video files by reading their binary content from the local filesystem and extracting comprehensive metadata including dimensions, frame rate, duration, codecs, and other technical properties. The stage handles both the file I/O operations and metadata extraction, storing results in the VideoTask.
The stage performs the following operations:
- Reads video file bytes from the local filesystem
- Extracts technical metadata using video analysis tools
- Validates metadata completeness and logs warnings for missing fields
- Optionally logs detailed video information when verbose mode is enabled
Parameters:
If True, logs detailed video information after successful processing
Read video file bytes from the local filesystem.
Reads the complete binary content of the video file and stores it in the video.source_bytes attribute. Handles file I/O errors gracefully and logs appropriate error messages.
Parameters:
Video object containing the input_video path to read from.
Returns: bool
True if file reading was successful, False if an error occurred.
Extract comprehensive metadata from video file and validate completeness.
Uses video analysis tools to extract technical metadata including dimensions, frame rate, duration, codecs, bit rate, and other properties. Logs warnings for critical missing metadata fields like codec and pixel format.
Parameters:
Video object with source_bytes populated for metadata extraction.
Returns: bool
True if metadata extraction completed successfully, False if extraction
Format video metadata into human-readable strings for logging output.
Converts raw metadata values into formatted strings with appropriate units and handles None values gracefully by substituting “unknown” placeholders. Used by _log_video_info for consistent log formatting.
Parameters:
Video object with populated metadata fields.
Returns: dict[str, str]
Dictionary mapping metadata field names to formatted string values,
Log comprehensive video information after successful processing.
Outputs detailed information about the processed video including file size, resolution, frame rate, duration, weight, and bit rate. This method is only called when verbose mode is enabled.
Parameters:
Video object with populated metadata fields.
Define the input attributes required by this stage.
Returns: list[str]
Tuple of (top_level_attrs, data_attrs) where:
Define the output attributes produced by this stage.
Returns: list[str]
Tuple of (top_level_attrs, data_attrs) where:
Process a video task by reading file bytes and extracting metadata.
Performs the complete video processing workflow including reading the video file from disk, extracting technical metadata, and optionally logging detailed information. Returns the same task with populated data.
Parameters:
VideoTask containing a Video object with input_video path set.
Returns: VideoTask
The same VideoTask with video.source_bytes and video.metadata populated.