# imageio.plugins.pyav.PyAVPlugin.init_video_stream

PyAVPlugin.init_video_stream(codec: str, *, fps: float = 24, pixel_format: str = None, max_keyframe_interval: int = None, force_keyframes: bool = None) → None

  Initialize a new video stream.

  This function adds a new video stream to the ImageResource using the selected encoder (codec), framerate, and colorspace.

  Parameters:
    codec str

      The codec to use, e.g. `"x264"` or `"vp9"`.

    fps float

      The desired framerate of the video stream (frames per second).

    pixel_format str

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

    max_keyframe_interval int

      The maximum distance between two intra frames (I-frames). Also known as GOP size. If unspecified use the codec’s default. Note that not every I-frame is a keyframe; see the notes for details.

    force_keyframes bool

      If True, limit inter frames dependency to frames within the current keyframe interval (GOP), i.e., force every I-frame to be a keyframe. If unspecified, use the codec’s default.

  Notes

  You can usually leave `max_keyframe_interval` and `force_keyframes` at their default values, unless you try to generate seek-optimized video or have a similar specialist use-case. In this case, `force_keyframes` controls the ability to seek to _every_ I-frame, and `max_keyframe_interval` controls how close to a random frame you can seek. Low values allow more fine-grained seek at the expense of file-size (and thus I/O performance).

previous

imageio.plugins.pyav.PyAVPlugin.metadata

next

imageio.plugins.pyav.PyAVPlugin.write_frame