videoflow.consumers package

This package contains a collection of consumers that implement the videoflow.core.node.ConsumerNode interface

Submodules

videoflow.consumers.basic module

class videoflow.consumers.basic.CommandlineConsumer(sep=' ', end='n')

Bases: videoflow.core.node.ConsumerNode

Writes the input received to the command line.

  • Arguments:
    • sep: separator to use between tokens.

    • end: end of line character

consume(item)

Prints item to the command line, adding an end of line character after it.

  • Arguments:
    • item: It can be anything that can be printed with the print() function

class videoflow.consumers.basic.FileAppenderConsumer

Bases: videoflow.core.node.ConsumerNode

consume(item)

Method definition that needs to be implemented by subclasses.

  • Arguments:
    • item: the item being received as input (or consumed).

class videoflow.consumers.basic.VoidConsumer

Bases: videoflow.core.node.ConsumerNode

Ignores the input received. Helpful in debugging flows.

consume(item)

Does nothing with the item passed

class videoflow.consumers.basic.WebhookConsumer

Bases: videoflow.core.node.ConsumerNode

consume(item)

Method definition that needs to be implemented by subclasses.

  • Arguments:
    • item: the item being received as input (or consumed).

videoflow.consumers.video module

class videoflow.consumers.video.VideofileWriter(video_file: str, swap_channels: bool = True, fps: int = 30)

Bases: videoflow.core.node.ConsumerNode

Opens a video file writer object and writes subsequent frames received into the object. If video file exists it overwrites it.

The video writer will open when it receives the first frame.

  • Arguments:
    • video_file: path to video. Folder where video lives must exist. Extension must be .avi

    • fps: frames per second

close()

Closes the video stream

consume(item: numpy.core.multiarray.array)

Receives the picture frame to append to the video and appends it to the video.

If it is the first frame received, it opens the video file and determines the height and width of the video from the dimensions of that first frame. Every subsequent frame is expected to have the same height and width. If it does not has it, it gets resized to it.

  • Arguments:
    • item: np.array of dimension (height, width, 3)

open()

We don’t open the video writer here. We need to wait for the first frame to arrive in order to determine the width and height of the video