videolib.video.Video

class Video(file_path, standard, mode, width=None, height=None, format=None, quantization=None, dither=False, out_dict={})[source]

Bases: object

Class defining a video. Reads/writes Frame objects to/from a file on the disk

Parameters:
  • file_path (str) – Path to file on the disk.

  • standard (Standard) – Color standard to which the data conforms.

  • mode (str) – Read/Write mode. Must be one of ‘r’ or ‘w’.

  • width (Optional[int]) – Width of each frame of the video. Required only in read mode.

  • height (Optional[int]) – Height of each frame of the video. Required only in read mode.

  • format (Optional[str]) – Raw/encoded format of the video.

  • quantization (Optional[int]) – Value to which data will be quantized and scaled back to original range.

  • dither (Optional[bool]) – Flag denoting whether dithering must be applied after quantization.

  • out_dict (Optional[Dict]) – Dictionary of ‘-vodec’ and/or ‘-crf’ parameters to pass to FFmpegWriter when writing encoded videos.

Methods

append

Appends frame to file on disk.

close

Close the file object associated with the video.

get_frame

Read a particular frame from the video (0-based indexing).

reset

Reset index of next to the start of the video.

write_frame

Adds frame to file on disk.

write_rgb_frame

Adds RGB frame array to file on disk.

write_yuv_frame

Adds YUV frame array to file on disk.

Attributes

bit_depth

append(frame)[source]

Appends frame to file on disk.

Parameters:

frame (Frame) – Frame object containing data to be appended.

Return type:

None

close()[source]

Close the file object associated with the video.

Return type:

None

get_frame(frame_ind)[source]

Read a particular frame from the video (0-based indexing).

Parameters:

frame_ind (int) – Index of frame to be read (0-based).

Returns:

Frame object containing the frame in YUV format.

Return type:

Frame

reset()[source]

Reset index of next to the start of the video.

Return type:

None

write_frame(frame)[source]

Adds frame to file on disk.

Parameters:

frame (Frame) – Frame object containing data to be written.

Return type:

None

write_rgb_frame(rgb)[source]

Adds RGB frame array to file on disk. :type rgb: ndarray :param rgb: RGB data to be written.

Return type:

None

write_yuv_frame(yuv)[source]

Adds YUV frame array to file on disk.

Parameters:

yuv (ndarray) – YUV data to be written.

Return type:

None