5.18. sail.MultiDecoder

Multichannel decoding interface, supporting simultaneous decoding of multichannel video.

5.18.1. __init__

Interface:
def __init__(self,
            queue_size: int = 10,
            tpu_id: int = 0,
            discard_mode: int = 0)

Parameters:

  • queue_size: int

For each video, the length of the decoded cached image queue.

  • tpu_id: int

Tpu id that used, which defaults to 0.

  • discard_mode: int

Data discard method when the cache reaches the maximum value. 0 indicates that data is not put into the cache; 1 indicates that the image of the queue header is poped , and then push into the decoded image. The default value is 0.

5.18.2. set_read_timeout

设置读取图片的超时时间,对read和read_接口生效,超时之后仍然没有获取到图像,结果就会返回。 Set the timeout period for reading images. This takes effect on the read and read_ interfaces.If the image is not obtained after the timeout, the result will be returned.

Interface:
def set_read_timeout(self, timeout: int) -> None

Parameters:

  • timeout: int

Timeout period, in seconds.

5.18.3. add_channel

Add a channel

Interface:
def add_channel(self,
            file_path: str,
            frame_skip_num: int = 0) -> int

Parameters:

  • file_path: str

The path or link to the video.

  • frame_skip_num: int

Number of active frame loss in decoded cache. The default value is 0, which means no active frame loss.

Returns

Returns the unique channel number corresponding to the video. The type is an integer.

5.18.4. del_channel

Delete a video channel that has been added.

Interface:
def del_channel(self, channel_idx: int) -> int

Parameters:

  • channel_idx: int

The channel number of the video to be deleted.

Returns

Return 0 on success and other values on failure.

5.18.5. clear_queue

Clears the image cache for the specified channel.

Interface:
def clear_queue(self, channel_idx: int) -> int

Parameters:

  • channel_idx: int

The channel number of the video to be deleted.

Returns:

Return 0 on success and other values on failure.

5.18.6. read

Gets an image from the specified video channel.

Interface1:
def read(self,
        channel_idx: int,
        image: BMImage,
        read_mode: int = 0) -> int

Parameters1:

  • channel_idx: int

The specified video channel number.

  • image: BMImage

The decoded image.

  • read_mode: int

Mode of obtaining images. 0 indicates that one image is read directly from the cache without waiting, and will be returned whether it is read or not. Others representations wait until the image is retrieved and then return.

Returns1:

Return 0 on success and other values on failure.

Interface2:
def read(self, channel_idx: int) -> BMImage

Parameters2:

  • channel_idx: int

The specified video channel number.

Returns2:

Returns the decoded image of type BMImage.

5.18.7. read_

Gets an image from the specified video channel, usually used with BMImageArray.

Interface1:
def read_(self,
        channel_idx: int,
        image: bm_image,
        read_mode: int=0) -> int

Parameters1:

  • channel_idx: int

The specified video channel number.

  • image: bm_image

The decoded image.

  • read_mode: int

Mode of obtaining images. 0 indicates that one image is read directly from the cache without waiting, and will be returned whether it is read or not. Others representations wait until the image is retrieved and then return.

Returns1:

Return 0 on success and other values on failure.

Interface2:
def read_(self, channel_idx: int) -> bm_image:

Parameters2:

  • channel_idx: int

The specified video channel number.

Returns2:

Returns the decoded image of type bm_image.

5.18.8. reconnect

Reconnect the video of the corresponding channel.

Interface:
def reconnect(self, channel_idx: int) -> int

Parameters:

  • channel_idx: int

The channel index of the input image.

Returns

Return 0 on success and other values on failure.

5.18.9. get_frame_shape

Get the image shape of the corresponding channel.

Interface:
def get_frame_shape(self, channel_idx: int) -> list[int]

Parameters:

  • channel_idx: int

The channel index of the input image.

Returns

Returns a list:[1, number of channels, image height, image width].

5.18.10. set_local_flag

Set whether the video is a local video. If it is not called, the video is represented as a network video stream.

Interface:
def set_local_flag(self, flag: bool) -> None:

Parameters:

  • flag: bool

Standard bit, if True, fixed decoding of 25 frames per second per video channel