# imageio.plugins.pyav.PyAVPlugin.write

PyAVPlugin.write(ndimage: ndarray | List[ndarray], *, codec: str = None, is_batch: bool = True, fps: int = 24, in_pixel_format: str = 'rgb24', out_pixel_format: str = None, filter_sequence: List[Tuple[str, str | dict]] = None, filter_graph: Tuple[dict, List] = None) → bytes | None

  Save a ndimage as a video.

  Given a batch of frames (stacked along the first axis) or a list of frames, encode them and add the result to the ImageResource.

  Parameters:
    ndimage ArrayLike, List[ArrayLike]

      The ndimage to encode and write to the ImageResource.

    codec str

      The codec to use when encoding frames. Only needed on first write and ignored on subsequent writes.

    is_batch bool

      If True (default), the ndimage is a batch of images, otherwise it is a single image. This parameter has no effect on lists of ndimages.

    fps str

      The resulting videos frames per second.

    in_pixel_format str

      The pixel format of the incoming ndarray. Defaults to “rgb24” and can be any stridable pix_fmt supported by FFmpeg.

    out_pixel_format str

      The pixel format to use while encoding frames. If None (default) use the codec’s default.

    filter_sequence List[str, str, dict]

      If not None, apply the given sequence of FFmpeg filters to each ndimage. Check the (module-level) plugin docs for details and examples.

    filter_graph(dict, List)

      If not None, apply the given graph of FFmpeg filters to each ndimage. The graph is given as a tuple of two dicts. The first dict contains a (named) set of nodes, and the second dict contains a set of edges between nodes of the previous dict. Check the (module-level) plugin docs for details and examples.

  Returns:
    encoded_image bytes or None

      If the chosen ImageResource is the special target `"<bytes>"` then write will return a byte string containing the encoded image data. Otherwise, it returns None.

  Notes

  When writing `<bytes>`, the video is finalized immediately after the first write call and calling write multiple times to append frames is not possible.

previous

imageio.plugins.pyav.PyAVPlugin.iter

next

imageio.plugins.pyav.PyAVPlugin.properties