Python API#
RTSP Stream Writer#
- class RTSPStreamWriter(*args: Any, **kwargs: Any)#
Bases:
WriterReplicator Writer that streams LdrColor frames over RTSP.
Supports two modes controlled by the
encodingparameter:"h264"(default): The LdrColor annotator is requested withinit_params={"compression": "h264"}so the render pipeline produces H.264-encoded bytes. These are passed tostream_video_pre_encoded_with_metadata, and also have the ability to enable per-frame SEI metadata injection."raw": The LdrColor annotator delivers a CUDA RGBA buffer which is passed tostream_video_cuda_buffer. The kit-livestream RTSP backend handles encoding internally. Metadata injection is not supported in this mode.
The RTSP server is started lazily on the first rendered frame. Calling
detach()(which happens automatically whenBaseWriterNoderesets on timeline stop) shuts the server down cleanly.- Parameters:
port – RTSP server port (1 to 65535). Each simultaneous stream needs a unique port.
mountPath – RTSP mount path (e.g.
/stream); must start with/.encoding –
"h264"(default) for pre-encoded H.264 with metadata support,"raw"for uncompressed CUDA path.width – Frame width in pixels. Used to configure the RTSP server when encoding is
"h264"(the encoded byte-stream does not carry resolution). Ignored when encoding is"raw"since the resolution is read from the CUDA buffer shape.height – Frame height in pixels. See
width.sensorSetName – Optional SRTX sensor-set name passed to the LdrColor annotator through
init_params.
- Raises:
ValueError – If
port,mountPath, orencodingis invalid.
Render Variable Utilities#
USD render-product / render-var helpers for the RTSP streaming extension.
These helpers exist to satisfy omni.replicator.srtx’s AnnotatorSRTX.attach
validation, which requires that the AOV’s RenderVar prim already exists as
a child of the render product (matched by sourceName) before a Replicator
Writer is attached.
- ensure_render_var_on_product(
- stage: pxr.Usd.Stage,
- render_product_path: str,
- aov_name: str,
- compression_type: str,
Ensure a
RenderVarfor the given AOV exists as a child of the render product and is inorderedVars.The helper is authoritative for the
srtx:compression:typeattribute on the rendervar prim: any pre-existing value is overwritten withcompression_type(which may be the empty string, the canonical SRTX “no compression / raw” signal). The attribute is created if missing.- Parameters:
stage – The USD stage.
render_product_path – Path to the render product prim.
aov_name – The AOV source name to match or create.
compression_type – SRTX compression type to author on the rendervar’s
srtx:compression:typeattribute. Pass""for raw / no compression, or one of the SRTX-recognised codec names (e.g."h264","h265","hevc").
- Returns:
A
(success, rendervar_path)tuple. On failurerendervar_pathisNoneandsuccessisFalse.