nemo_rl.models.generation.vllm.video_utils#
Module Contents#
Functions#
Convert a timestamp according to the configured sampling contract. |
|
Return the shared synthetic timing contract for cached video frames. |
|
Build a compact native-video URL backed by lossless cached PNG frames. |
|
Load an internal cached-frame manifest passed through vLLM VideoMediaIO. |
|
Find the decodable tail when container metadata overstates frame count. |
|
Decode sampled frames, recovering from overstated container metadata. |
|
Decode video with the repository’s optional TorchCodec dependency. |
|
Use TorchCodec for raw Nemotron video bytes parsed by vLLM’s HTTP server. |
|
Load sampled RGB frames through the supported TorchCodec backend. |
Data#
API#
- nemo_rl.models.generation.vllm.video_utils.VideoSamplingStyle#
None
- nemo_rl.models.generation.vllm.video_utils._TORCHCODEC_END_OF_STREAM_ERROR#
‘Requested next frame while there are no more frames left to decode.’
- nemo_rl.models.generation.vllm.video_utils._CACHED_VIDEO_FRAME_MANIFEST_MAGIC#
b’NEMO_RL_CACHED_VIDEO_FRAMES_V1\n’
- nemo_rl.models.generation.vllm.video_utils._CACHED_VIDEO_FRAME_MANIFEST_MIME#
‘video/x-nemo-rl-cached-frames’
- nemo_rl.models.generation.vllm.video_utils._round_video_frame_count(
- num_frames: int,
- *,
- total_frames_in_file: int,
- max_frames: int,
- temporal_patch_size: int,
- nemo_rl.models.generation.vllm.video_utils._timestamp_to_video_frame_index(
- timestamp_s: float,
- fps: float,
- total_frames: int,
- sampling_style: nemo_rl.models.generation.vllm.video_utils.VideoSamplingStyle,
Convert a timestamp according to the configured sampling contract.
- nemo_rl.models.generation.vllm.video_utils._select_video_frame_count(
- *,
- requested_num_frames: int,
- total_frames_in_file: int,
- temporal_patch_size: int,
- sampling_style: nemo_rl.models.generation.vllm.video_utils.VideoSamplingStyle,
- nemo_rl.models.generation.vllm.video_utils._compute_video_timestamps(
- total_duration: float,
- num_frames: int,
- total_frames_in_file: int,
- original_num_frames: int,
- temporal_patch_size: int,
- sampling_style: nemo_rl.models.generation.vllm.video_utils.VideoSamplingStyle,
- nemo_rl.models.generation.vllm.video_utils._build_video_metadata(
- *,
- fps: float,
- total_frames: int,
- sampled_indices: list[int],
- backend: str,
- sampling_style: nemo_rl.models.generation.vllm.video_utils.VideoSamplingStyle,
- nemo_rl.models.generation.vllm.video_utils._resolve_cached_video_media_path(value: str) pathlib.Path#
- nemo_rl.models.generation.vllm.video_utils.build_cached_video_frame_metadata(
- num_frames: int,
Return the shared synthetic timing contract for cached video frames.
- nemo_rl.models.generation.vllm.video_utils.build_cached_video_frame_data_url(frame_paths: list[str]) str#
Build a compact native-video URL backed by lossless cached PNG frames.
- nemo_rl.models.generation.vllm.video_utils._load_cached_video_frame_manifest(
- data: bytes,
- *,
- num_frames: int,
Load an internal cached-frame manifest passed through vLLM VideoMediaIO.
- nemo_rl.models.generation.vllm.video_utils._is_torchcodec_end_of_stream_error(exc: RuntimeError) bool#
- nemo_rl.models.generation.vllm.video_utils._torchcodec_sample_indices(
- *,
- total_frames: int,
- fps: float,
- requested_num_frames: int,
- temporal_patch_size: int,
- sampling_style: nemo_rl.models.generation.vllm.video_utils.VideoSamplingStyle,
- nemo_rl.models.generation.vllm.video_utils._find_torchcodec_decodable_frame_count(
- decoder_factory: collections.abc.Callable[[], Any],
- declared_total_frames: int,
Find the decodable tail when container metadata overstates frame count.
- nemo_rl.models.generation.vllm.video_utils._decode_torchcodec_video(
- source: Any,
- *,
- requested_num_frames: int,
- temporal_patch_size: int,
- sampling_style: nemo_rl.models.generation.vllm.video_utils.VideoSamplingStyle,
- source_description: str,
- initial_decoder: Any | None = None,
Decode sampled frames, recovering from overstated container metadata.
- nemo_rl.models.generation.vllm.video_utils._load_video_frames_torchcodec_with_metadata(
- video_path: str,
- *,
- num_frames: int,
- temporal_patch_size: int,
- sampling_style: nemo_rl.models.generation.vllm.video_utils.VideoSamplingStyle,
Decode video with the repository’s optional TorchCodec dependency.
- nemo_rl.models.generation.vllm.video_utils.register_torchcodec_vllm_video_loader(
- *,
- sampling_style: nemo_rl.models.generation.vllm.video_utils.VideoSamplingStyle,
- temporal_patch_size: int,
Use TorchCodec for raw Nemotron video bytes parsed by vLLM’s HTTP server.
vLLM’s
nemotron_vlloader defaults to OpenCV, while NeMo-RL deliberately does not ship OpenCV or PyAV. Registering this structuralVideoLoaderimplementation under the same extension name keeps vLLM’s media connector contract and makes rollout decoding match policy-logprob preprocessing.The caller supplies the same validated values materialized into the policy data configuration. Registration is therefore not conditional on process environment state.
- nemo_rl.models.generation.vllm.video_utils.load_video_frames_with_metadata(
- video_path: str,
- *,
- num_frames: int,
- temporal_patch_size: int,
- sampling_style: nemo_rl.models.generation.vllm.video_utils.VideoSamplingStyle,
Load sampled RGB frames through the supported TorchCodec backend.