cv3.video.Video
- cv3.video.Video(path, mode='r', **kwds)[source]
Factory function to create VideoCapture or VideoWriter instances.
- Parameters:
path (str or Path) – Path to the video file or camera index.
mode (str, optional) – Mode of operation. ‘r’ for reading, ‘w’ for writing. Defaults to ‘r’.
**kwds – Additional keyword arguments passed to VideoWriter (only in ‘w’ mode).
- Returns:
VideoCapture instance if mode=’r’, VideoWriter instance if mode=’w’.
- Return type:
- Raises:
TypeError – If keyword arguments are passed in ‘r’ mode.
Examples
>>> # Create a video reading stream >>> reader = Video('video.mp4', mode='r') >>> >>> # Create a video writing stream >>> writer = Video('output.mp4', mode='w') >>> >>> # Create a video writing stream with custom parameters >>> writer = Video('output.mp4', mode='w', fps=30, fourcc='mp4v')