imageio.plugins.pyav.PyAVPlugin.init_video_stream#

PyAVPlugin.init_video_stream(codec: str, *, fps: float = 24, pixel_format: Optional[str] = None, max_keyframe_interval: Optional[int] = None, force_keyframes: Optional[bool] = None) None[source]#

Initialize a new video stream.

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

Parameters
codecstr

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

fpsfloat

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

pixel_formatstr

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

max_keyframe_intervalint

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_keyframesbool

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).