add_video#
- NDWSubplot.add_video(data, dims, display_dims, rgb_dim=None, colorspace='yuv420p', colorrange='limited', slicer_type=VideoSlicer, window_funcs=None, window_order=None, spatial_func=None, slider_maps=None, name=None, graphic_kwargs=None)[source]#
Add a video to this subplot.
This is usually what you want for video data. Videos are usually stored in a YUV colorspace, and sending the YUV planes to the GPU is much faster than converting each frame to RGB and copying it into an sRGB texture.
We strongly recommend using
asyncvideofor thedataobject, it is the most efficient async video reader that we know of for visualization purposes: https://pypi.org/project/asyncvideo/Same as
add_nd_image()but uses aVideoSlicerand YUV defaults. TheVideoSlicerreads the frame at the current index directly, it does not applywindow_funcs.- Parameters:
data (ArrayProtocol or None) – video data, an object that decodes frames on demand, ex: an
asyncvideoreader. PassNoneto create theNDImagewithout a graphic and set the data later usingnd_image.data, the slider dims then require an explicit reference range in theNDWidget.dims (Sequence[str]) – name for every dim of
data, in order. They do not need to be in display order.display_dims (tuple[str, str] | tuple[str, str, str]) – The 2 or 3 spatial dims in display order, see
add_nd_image().rgb_dim (str, optional) – Name of the RGB(A) dim, if present. It must be listed in
display_dimsand be of size 3 or 4.colorspace ("yuv420p" | "yuv444p" | "srgb" | "tex-srgb" | "physical", default "yuv420p") – Colorspace in which to interpret the data. The YUV colorspaces are rendered using an
ImageYUVGraphic, seeImageYUVGraphic. The RGB colorspaces are rendered using anImageGraphicorImageVolumeGraphic, seeImageGraphic.colorrange ("full" | "limited", default "limited") – Used only for the YUV colorspaces, see
ImageYUVGraphic. Most videos use “limited”.slicer_type (type[NDImageSlicer], default
VideoSlicer) –NDImageSlicersubclass that manages the data and produces the data slices.window_funcs (dict[str, tuple[WindowFuncCallable | None, int | float | None]], optional) – Per-slider-dim window functions, see
add_nd_image(). Ignored by the defaultVideoSlicer.window_order (tuple[str, ...], optional) – Order in which the window functions are applied across dims. Ignored by the default
VideoSlicer.spatial_func (Callable[[ArrayProtocol], ArrayProtocol], optional) – A function applied to the spatial slice right before rendering. It is given the frame in
display_dimsorder, i.e. the array as it is rendered, and must return an array with those same dims.slider_maps (dict mapping dim_name -> Callable, an ArrayLike, or None, optional) – Per-slider-dim mapping from reference-space values to local array indices, ex: an array of frame timestamps to map seconds onto frame indices. See
add_nd_image().name (str, optional) – Name for this
NDGraphic, used to retrieve it withnd_subplot[name].graphic_kwargs (dict, optional) – passed to the underlying image graphic
- Return type: