Xvideos documentation

Xvideos is a lightweight single class library for background video reading. The VideoReader class works in 2 threads, which allows you to efficiently read the video with its parallel processing.

class xvideos.reader.VideoReader(source: Union[str, int], batch_size: int = 1, buffer_size: int = 1)

Class for video reading using opencv.

source

Video source.

Type

Union[str, int]

batch_size

Number of frames, which will be returned.

Type

int, default=1

buffer_size

Number of frames in internal buffer.

Type

int, default=1

Examples

>>> from xvideos import VideoReader
...
... reader = VideoReader(source=0, batch_size=32, buffer_size=128)
... while True:
...     flag, batch = reader.get()
...     if not flag:
...         break

You can read video in while true loop and stop him when video has ended.

>>> from xvideos import VideoReader
...
... reader = VideoReader(source='./test.mp4')
... reader.info

Using property “info” you can get information about video (for example: fps, number of frames and video duration).

get() Tuple[bool, List]

Get batch of frames from buffer.

Returns

pair (bool flag, list of frames). If capture has ended, then flag = False, else flag = True

Return type

Tuple[bool, List]

property info

Info of video capture