maix.video

maix.video module

You can use maix.video to access this module with MaixPy
This module is generated from MaixPy and MaixCDK

Module

No module

Enum

VideoType

Video type

item describe
values VIDEO_NONE: format invalid
VIDEO_ENC_H265_CBR: Deprecated
VIDEO_ENC_MP4_CBR: Deprecated
VIDEO_DEC_H265_CBR: Deprecated
VIDEO_DEC_MP4_CBR: Deprecated
VIDEO_H264_CBR: Deprecated
VIDEO_H265_CBR: Deprecated
VIDEO_H264_CBR_MP4: Deprecated
VIDEO_H265_CBR_MP4: Deprecated
VIDEO_H264:
VIDEO_H264_MP4:
VIDEO_H264_FLV:
VIDEO_H265:
VIDEO_H265_MP4:

C++ defination code:

enum VideoType
    {
        VIDEO_NONE = 0,  // format invalid
        VIDEO_ENC_H265_CBR,     // Deprecated
        VIDEO_ENC_MP4_CBR,      // Deprecated
        VIDEO_DEC_H265_CBR,     // Deprecated
        VIDEO_DEC_MP4_CBR,      // Deprecated
        VIDEO_H264_CBR,         // Deprecated
        VIDEO_H265_CBR,         // Deprecated
        VIDEO_H264_CBR_MP4,     // Deprecated
        VIDEO_H265_CBR_MP4,     // Deprecated

        VIDEO_H264,
        VIDEO_H264_MP4,
        VIDEO_H264_FLV,
        VIDEO_H265,
        VIDEO_H265_MP4,
    }

MediaType

Video type

item describe
values MEDIA_TYPE_UNKNOWN: Represents an unknown media type, which is usually treated as AVMEDIA_TYPE_DATA.
MEDIA_TYPE_VIDEO: Represents a video stream, such as video content encoded in H.264, MPEG-4, etc.
MEDIA_TYPE_AUDIO: Represents an audio stream, such as audio content encoded in AAC, MP3, etc.
MEDIA_TYPE_DATA: Represents opaque data streams that are usually continuous. This type of stream is not necessarily audio or video and may be used for other data purposes.
MEDIA_TYPE_SUBTITLE: Represents a subtitle stream used for displaying text or subtitle information, such as SRT, ASS, etc.
MEDIA_TYPE_ATTACHMENT: Represents attachment streams that are usually sparse. Attachment streams can include images, fonts, or other files that need to be bundled with the media.
MEDIA_TYPE_NB: Represents the number of media types (count) and indicates the total number of media types defined in this enumeration. It is not a media type itself but is used for counting enumeration items.

C++ defination code:

enum MediaType
    {
        MEDIA_TYPE_UNKNOWN = -1,    // Represents an unknown media type, which is usually treated as AVMEDIA_TYPE_DATA.
        MEDIA_TYPE_VIDEO,           // Represents a video stream, such as video content encoded in H.264, MPEG-4, etc.
        MEDIA_TYPE_AUDIO,           // Represents an audio stream, such as audio content encoded in AAC, MP3, etc.
        MEDIA_TYPE_DATA,            // Represents opaque data streams that are usually continuous. This type of stream is not necessarily audio or video and may be used for other data purposes.
        MEDIA_TYPE_SUBTITLE,        // Represents a subtitle stream used for displaying text or subtitle information, such as SRT, ASS, etc.
        MEDIA_TYPE_ATTACHMENT,      // Represents attachment streams that are usually sparse. Attachment streams can include images, fonts, or other files that need to be bundled with the media.
        MEDIA_TYPE_NB               // Represents the number of media types (count) and indicates the total number of media types defined in this enumeration. It is not a media type itself but is used for counting enumeration items.
    }

Variable

Function

timebase_to_us

def timebase_to_us(timebase: list[int], value: int) -> float

Convert a value in timebase units to microseconds. value * 1000000 / (timebase[1] / timebase[0])

item description
param timebse: Time base, used as the unit for calculating playback time. It must be an array containing two parameters,
in the format [num, den], where the first parameter is the numerator of the time base, and the second parameter is the denominator of the time base.
value: Input value
return Return the result in microseconds.

C++ defination code:

double timebase_to_us(std::vector<int> timebase, uint64_t value)

timebase_to_ms

def timebase_to_ms(timebase: list[int], value: int) -> float

Convert a value in timebase units to milliseconds.

item description
param timebse: Time base, used as the unit for calculating playback time. It must be an array containing two parameters,
in the format [num, den], where the first parameter is the numerator of the time base, and the second parameter is the denominator of the time base.
value: Input value
return Return the result in milliseconds.

C++ defination code:

double timebase_to_ms(std::vector<int> timebase, uint64_t value)

Class

Context

Context class

C++ defination code:

class Context

__init__

def __init__(self, media_type: MediaType, timebase: list[int]) -> None

Construct a new Context object

item description
type func
param media_type: enable capture, if true, you can use capture() function to get an image object
timebase: Time base, used as the unit for calculating playback time. It must be an array containing two parameters,
in the format [num, den], where the first parameter is the numerator of the time base, and the second parameter is the denominator of the time base.
static False

C++ defination code:

Context(video::MediaType media_type, std::vector<int> timebase)

audio_sample_rate

def audio_sample_rate(self) -> int

Get sample rate of audio (only valid in the context of audio)

item description
type func
return sample rate
static False

C++ defination code:

int audio_sample_rate()

audio_sample_rate (overload 1)

Get sample rate of audio (only valid in the context of audio)

item description
type func
return sample rate
static False

C++ defination code:

int audio_sample_rate()

audio_channels

def audio_channels(self) -> int

Get channels of audio (only valid in the context of audio)

item description
type func
return channels
static False

C++ defination code:

int audio_channels()

audio_channels (overload 1)

Get channels of audio (only valid in the context of audio)

item description
type func
return channels
static False

C++ defination code:

int audio_channels()

audio_format

def audio_format(self) -> maix.audio.Format

Get format of audio (only valid in the context of audio)

item description
type func
return audio format. @see audio::Format
static False

C++ defination code:

audio::Format audio_format()

audio_format (overload 1)

Get format of audio (only valid in the context of audio)

item description
type func
return audio format. @see audio::Format
static False

C++ defination code:

audio::Format audio_format()

set_pcm

def set_pcm(self, data: maix.Bytes(bytes), duration: int = 0, pts: int = 0, copy: bool = True) -> maix.err.Err

Set pcm data (only valid in the context of audio)

item description
type func
param duration: Duration of the current pcm. unit: timebase
pts: The start time of this pcm playback. If it is 0, it means this parameter is not supported. unit: timebase
return err::Err
static False

C++ defination code:

err::Err set_pcm(maix::Bytes *data, int duration = 0, uint64_t pts = 0, bool copy = true)

get_pcm

def get_pcm(*args, **kwargs)

Get pcm data (only valid in the context of audio)

item description
type func
attention Note that if you call this interface, you are responsible for releasing the memory of the data, and this interface cannot be called again.
return Bytes
static False

C++ defination code:

Bytes *get_pcm()

image

def image(self) -> maix.image.Image

Retrieve the image data to be played.

item description
type func
attention Note that if you call this interface, you are responsible for releasing the memory of the image, and this interface cannot be called again.
static False

C++ defination code:

image::Image *image()

media_type

def media_type(self) -> MediaType

Get the media type to determine whether it is video, audio, or another media type.

item description
type func
static False

C++ defination code:

video::MediaType media_type()

pts

def pts(self) -> int

Get the start time of the current playback., in units of time base.

item description
type func
static False

C++ defination code:

uint64_t pts()

last_pts

def last_pts(self) -> int

Get the start time of the previous playback, in units of time base.

item description
type func
static False

C++ defination code:

uint64_t last_pts()

timebase

def timebase(self) -> list[int]

Get the time base.

item description
type func
static False

C++ defination code:

std::vector<int> timebase()

duration

def duration(self) -> int

Duration of the current frame. unit: timebase

item description
type func
static False

C++ defination code:

int duration()

duration_us

def duration_us(self) -> int

Duration of the current frame. unit: us

item description
type func
static False

C++ defination code:

uint64_t duration_us()

Frame

Frame class

C++ defination code:

class Frame

to_bytes

def to_bytes(*args, **kwargs)

Get raw data of packet

item description
type func
param copy: if true, will alloc memory and copy data to new buffer
return raw data
static False

C++ defination code:

Bytes *to_bytes(bool copy = false)

size

def size(self) -> int

Get raw data size of packet

item description
type func
return size of raw data
static False

C++ defination code:

size_t size()

is_valid

def is_valid(self) -> bool

Check packet is valid

item description
type func
return true, packet is valid; false, packet is invalid
static False

C++ defination code:

bool is_valid()

set_pts

def set_pts(self, pts: int) -> None

Set pts

item description
type func
param pts: presentation time stamp. unit: time_base
static False

C++ defination code:

void set_pts(uint64_t pts)

set_dts

def set_dts(self, dts: int) -> None

Set dts

item description
type func
param dts: decoding time stamp. unit: time_base
static False

C++ defination code:

void set_dts(uint64_t dts)

set_duration

def set_duration(self, duration: int) -> None

Set duration

item description
type func
param duration: packet display time. unit: time_base
static False

C++ defination code:

void set_duration(uint64_t duration)

get_pts

def get_pts(self) -> int

Set pts

item description
type func
param pts: presentation time stamp. unit: time_base
return pts value
static False

C++ defination code:

uint64_t get_pts()

get_dts

def get_dts(self) -> int

Set dts

item description
type func
param dts: decoding time stamp. unit: time_base
return dts value
static False

C++ defination code:

uint64_t get_dts()

get_duration

def get_duration(self) -> int

Get duration

item description
type func
return duration value
static False

C++ defination code:

uint64_t get_duration()

type

def type(self) -> VideoType

Get frame type

item description
type func
return video type. @see video::VideoType
static False

C++ defination code:

video::VideoType type()

Packet

Packet class

C++ defination code:

class Packet

__init__

def __init__(self, data: int, len: int, pts: int = -1, dts: int = -1, duration: int = 0) -> None

Packet number (pair of numerator and denominator).

item description
type func
param data: src data pointer, use pointers directly without copying.
Note: this object will try to free this memory
len: data len
pts: presentation time stamp. unit: time_base
dts: decoding time stamp. unit: time_base
duration: packet display time. unit: time_base
static False

C++ defination code:

Packet(uint8_t *data, int len, uint64_t pts = -1, uint64_t dts = -1, int64_t duration = 0)

get

def get(self) -> list[int]

Get raw data of packet

item description
type func
return raw data
static False

C++ defination code:

std::vector<uint8_t> get()

data

def data(self) -> int

Get raw data of packet

item description
type func
return raw data
static False

C++ defination code:

uint8_t *data()

data_size

def data_size(self) -> int

Get raw data size of packet

item description
type func
return size of raw data
static False

C++ defination code:

size_t data_size()

is_valid

def is_valid(self) -> bool

Check packet is valid

item description
type func
return true, packet is valid; false, packet is invalid
static False

C++ defination code:

bool is_valid()

set_pts

def set_pts(self, pts: int) -> None

Set pts

item description
type func
param pts: presentation time stamp. unit: time_base
return true, packet is valid; false, packet is invalid
static False

C++ defination code:

void set_pts(uint64_t pts)

set_dts

def set_dts(self, dts: int) -> None

Set dts

item description
type func
param dts: decoding time stamp. unit: time_base
return true, packet is valid; false, packet is invalid
static False

C++ defination code:

void set_dts(uint64_t dts)

set_duration

def set_duration(self, duration: int) -> None

Set duration

item description
type func
param duration: packet display time. unit: time_base
return true, packet is valid; false, packet is invalid
static False

C++ defination code:

void set_duration(uint64_t duration)

Encoder

Encode class

C++ defination code:

class Encoder

__init__

def __init__(self, path: str = '', width: int = 2560, height: int = 1440, format: maix.image.Format = ..., type: VideoType = ..., framerate: int = 30, gop: int = 50, bitrate: int = 3000000, time_base: int = 1000, capture: bool = False, block: bool = True) -> None

Construct a new Video object

item description
type func
param width: picture width. this value may be set automatically. default is 2560.
height: picture height. this value may be set automatically. default is 1440.
format: picture format. default is image::Format::FMT_YVU420SP. @see image::Format
type: video encode/decode type. default is ENC_H265_CBR. @see EncodeType
framerate: frame rate. framerate default is 30, means 30 frames per second
for video. 1/time_base is not the average frame rate if the frame rate is not constant.
gop: for h264/h265 encoding, the interval between two I-frames, default is 50.
bitrate: for h264/h265 encoding, used to limit the bandwidth used by compressed data, default is 3000kbps
time_base: frame time base. time_base default is 1000, means 1/1000 ms (not used)
capture: enable capture, if true, you can use capture() function to get an image object
block: This parameter determines whether encoding should block until it is complete.
If set to true, it will wait until encoding is finished before returning.
If set to false, it will return the current encoding result on the next call.
static False

C++ defination code:

Encoder(std::string path = "", int width = 2560, int height = 1440, image::Format format = image::Format::FMT_YVU420SP, video::VideoType type = video::VideoType::VIDEO_H264, int framerate = 30, int gop = 50, int bitrate = 3000 * 1000, int time_base = 1000, bool capture = false, bool block = true)

bind_camera

def bind_camera(self, camera: maix.camera.Camera) -> maix.err.Err

Bind camera

item description
type func
param camera: camera object
return error code, err::ERR_NONE means success, others means failed
static False

C++ defination code:

err::Err bind_camera(camera::Camera *camera)

encode

def encode(self, img: maix.image.Image = ..., pcm: maix.Bytes(bytes) = b'') -> Frame

Encode image.

item description
type func
param img: the image will be encode.
if the img is NULL, this function will try to get image from camera, you must use bind_camera() function to bind the camera.
pcm: the pcm data will be encode.
return encode result
static False

C++ defination code:

video::Frame *encode(image::Image *img = maix::video::Encoder::NoneImage, Bytes *pcm = maix::video::Encoder::NoneBytes)

capture

def capture(self) -> maix.image.Image

Capture image

item description
type func
attention Each time encode is called, the last captured image will be released.
return error code
static False

C++ defination code:

image::Image *capture()

width

def width(self) -> int

Get video width

item description
type func
return video width
static False

C++ defination code:

int width()

height

def height(self) -> int

Get video height

item description
type func
return video height
static False

C++ defination code:

int height()

type

def type(self) -> VideoType

Get video encode type

item description
type func
return VideoType
static False

C++ defination code:

video::VideoType type()

framerate

def framerate(self) -> int

Get video encode framerate

item description
type func
return frame rate
static False

C++ defination code:

int framerate()

gop

def gop(self) -> int

Get video encode gop

item description
type func
return gop value
static False

C++ defination code:

int gop()

bitrate

def bitrate(self) -> int

Get video encode bitrate

item description
type func
return bitrate value
static False

C++ defination code:

int bitrate()

time_base

def time_base(self) -> int

Get video encode time base

item description
type func
return time base value
static False

C++ defination code:

int time_base()

Decoder

Decoder class

C++ defination code:

class Decoder

__init__

def __init__(self, path: str, format: maix.image.Format = ...) -> None

Construct a new decoder object

item description
type func
param path: Path to the file to be decoded. Supports files with .264 and .mp4 extensions. Note that only mp4 files containing h.264 streams are supported.
format: Decoded output format, currently only support YUV420SP
static False

C++ defination code:

Decoder(std::string path, image::Format format = image::Format::FMT_YVU420SP)

decode_video

def decode_video(self, block: bool = True) -> Context

Decode the video stream, returning the image of the next frame each time.

item description
type func
param block: Whether it blocks or not. If true, it will wait for the decoding to complete and return the current frame.
If false, it will return the result of the previous frame's decoding. If the previous frame's decoding result is empty,
it will return an unknown Context, and you can use the media_type method of the Context to determine if a valid result exists.
default is true.
return Decoded context information.
static False

C++ defination code:

video::Context * decode_video(bool block = true)

decode_audio

def decode_audio(self) -> Context

Decode the video stream, returning the image of the next frame each time.

item description
type func
return Decoded context information.
static False

C++ defination code:

video::Context * decode_audio()

decode

def decode(self, block: bool = True) -> Context

Decode the video and audio stream

item description
type func
param block: Whether it blocks or not. If true, it will wait for the decoding to complete and return the current frame.
If false, it will return the result of the previous frame's decoding. If the previous frame's decoding result is empty,
it will return an unknown Context, and you can use the media_type method of the Context to determine if a valid result exists.
default is true.
return Decoded context information.
static False

C++ defination code:

video::Context * decode(bool block = true)

width

def width(self) -> int

Get the video width

item description
type func
return video width
static False

C++ defination code:

int width()

height

def height(self) -> int

Get the video height

item description
type func
return video height
static False

C++ defination code:

int height()

bitrate

def bitrate(self) -> int

Get the video bitrate

item description
type func
return bitrate value
static False

C++ defination code:

int bitrate()

fps

def fps(self) -> int

Get the video fps

item description
type func
return fps value
static False

C++ defination code:

int fps()

seek

def seek(self, time: float = -1) -> float

Seek to the required playback position

item description
type func
param time: timestamp value, unit: s
return return the current position, unit: s
static False

C++ defination code:

double seek(double time = -1)

duration

def duration(self) -> float

Get the maximum duration of the video. If it returns 0, it means it cannot be predicted.

item description
type func
return duration value, unit: s
static False

C++ defination code:

double duration()

timebase

def timebase(self) -> list[int]

Get the time base.

item description
type func
static False

C++ defination code:

std::vector<int> timebase()

has_audio

def has_audio(self) -> bool

If find audio data, return true

item description
type func
static False

C++ defination code:

bool has_audio()

has_video

def has_video(self) -> bool

If find video data, return true

item description
type func
static False

C++ defination code:

bool has_video()

Video

Video class

C++ defination code:

class Video

__init__

def __init__(self, path: str = '', width: int = 2560, height: int = 1440, format: maix.image.Format = ..., time_base: int = 30, framerate: int = 30, capture: bool = False, open: bool = True) -> None

Construct a new Video object

item description
type func
param path: video path. the path determines the location where you load or save the file, if path is none, the video module will not save or load file.
xxx.h265 means video format is H265, xxx.mp4 means video format is MP4
width: picture width. this value may be set automatically. default is 2560.
height: picture height. this value may be set automatically. default is 1440.
format: picture pixel format. this value may be set automatically. default is FMT_YVU420SP.
time_base: frame time base. time_base default is 30, means 1/30 ms
framerate: frame rate. framerate default is 30, means 30 frames per second
for video. 1/time_base is not the average frame rate if the frame rate is not constant.
capture: enable capture, if true, you can use capture() function to get an image object
open: If true, video will automatically call open() after creation. default is true.
static False

C++ defination code:

Video(std::string path = std::string(), int width = 2560, int height = 1440, image::Format format = image::Format::FMT_YVU420SP, int time_base = 30, int framerate = 30, bool capture = false, bool open = true)

open

def open(self, path: str = '', fps: float = 30.0) -> maix.err.Err

Open video and run

item description
type func
param path: video path. the path determines the location where you load or save the file, if path is none, the video module will not save or load file.
xxx.h265 means video format is H265, xxx.mp4 means video format is MP4
fps: video fps
return error code, err::ERR_NONE means success, others means failed
static False

C++ defination code:

err::Err open(std::string path = std::string(), double fps = 30.0)

close

def close(self) -> None

Close video

item description
type func
static False

C++ defination code:

void close()

bind_camera

def bind_camera(self, camera: maix.camera.Camera) -> maix.err.Err

Bind camera

item description
type func
param camera: camera object
return error code, err::ERR_NONE means success, others means failed
static False

C++ defination code:

err::Err bind_camera(camera::Camera *camera)

encode

def encode(self, img: maix.image.Image = ...) -> Packet

Encode image.

item description
type func
param img: the image will be encode.
if the img is NULL, this function will try to get image from camera, you must use bind_camera() function to bind the camera.
return encode result
static False

C++ defination code:

video::Packet *encode(image::Image *img = maix::video::Video::NoneImage)

decode

def decode(self, frame: Frame = None) -> maix.image.Image

Decode frame

item description
type func
param frame: the frame will be decode
return decode result
static False

C++ defination code:

image::Image *decode(video::Frame *frame = nullptr)

finish

def finish(self) -> maix.err.Err

Encode or decode finish

item description
type func
return error code
static False

C++ defination code:

err::Err finish()

capture

def capture(self) -> maix.image.Image

Capture image

item description
type func
attention Each time encode is called, the last captured image will be released.
return error code
static False

C++ defination code:

image::Image *capture()

is_recording

def is_recording(self) -> bool

Check if video is recording

item description
type func
return true if video is recording, false if not
static False

C++ defination code:

bool is_recording()

is_opened

def is_opened(self) -> bool

Check if video is opened

item description
type func
return true if video is opened, false if not
static False

C++ defination code:

bool is_opened()

is_closed

def is_closed(self) -> bool

check video device is closed or not

item description
type func
return closed or not, bool type
static False

C++ defination code:

bool is_closed()

width

def width(self) -> int

Get video width

item description
type func
return video width
static False

C++ defination code:

int width()

height

def height(self) -> int

Get video height

item description
type func
return video height
static False

C++ defination code:

int height()

VideoRecorder

Video Recorder class. This module is not fully supported and may be deprecated in the future.

C++ defination code:

class VideoRecorder

__init__

def __init__(self, open: bool = True) -> None

Construct a new VideoRecorder object. This is an object that integrates recording, video capturing, and display functions, which can be used to achieve high-resolution video input when needed.

item description
type func
param open: If true, video will automatically call open() after creation. default is true.
static False

C++ defination code:

VideoRecorder(bool open = true)

lock

def lock(self, timeout: int = -1) -> maix.err.Err

lock video

item description
type func
param timeout: timeout in ms. unit:ms
return error code
static False

C++ defination code:

err::Err lock(int64_t timeout = -1)

unlock

def unlock(self) -> maix.err.Err

unlock video

item description
type func
return error code
static False

C++ defination code:

err::Err unlock()

open

def open(self) -> maix.err.Err

Start a thread to handle the input function.

item description
type func
return error code
static False

C++ defination code:

err::Err open()

close

def close(self) -> maix.err.Err

Stop the thread, and reset the object.

item description
type func
return error code
static False

C++ defination code:

err::Err close()

is_opened

def is_opened(self) -> bool

Check whether the object is opened.

item description
type func
static False

C++ defination code:

bool is_opened()

bind_display

def bind_display(self, display: maix.display.Display, fit: maix.image.Fit = ...) -> maix.err.Err

Bind a Display object. if this object is not bound, it will not be displayed.

item description
type func
param display: display object
fit: fit mode. It is recommended to fill in FIT_COVER or FIT_FILL. For maixcam, using FIT_CONTAIN may affect the
functionality of the second layer created by add_channel() in the Display. default is FIT_COVER.
return error code
static False

C++ defination code:

err::Err bind_display(display::Display *display, image::Fit fit = image::FIT_COVER)

bind_camera

def bind_camera(self, camera: maix.camera.Camera) -> maix.err.Err

Bind a Camera object. if this object is not bound, images cannot be captured.

item description
type func
param camera: camera object
return error code
static False

C++ defination code:

err::Err bind_camera(camera::Camera *camera)

bind_audio

def bind_audio(self, audio: maix.audio.Recorder) -> maix.err.Err

Bind a AudioRecorder object. if this object is not bound, audio cannot be captured.

item description
type func
param audio: audio recorder object
return error code
static False

C++ defination code:

err::Err bind_audio(audio::Recorder *audio)

bind_imu

def bind_imu(self, imu: capsule) -> maix.err.Err

Bind a IMU object. if this object is not bound, imu data cannot be captured.

item description
type func
param imu: imu object
return error code
static False

C++ defination code:

err::Err bind_imu(void *imu)

reset

def reset(self) -> maix.err.Err

Reset the video recorder.

item description
type func
note It will not reset the bound object; if you have already bound the display using bind_display(), there is no need to rebind the display after calling reset().
return error code
static False

C++ defination code:

err::Err reset()

config_path

def config_path(self, path: str) -> maix.err.Err

The recorded video will be saved to this path, and this API cannot be called during runtime.

item description
type func
param path: The path of the video file to be saved
return error code
static False

C++ defination code:

err::Err config_path(std::string path)

get_path

def get_path(self) -> str

Get the path of the video file to be saved

item description
type func
return path
static False

C++ defination code:

std::string get_path()

config_snapshot

def config_snapshot(self, enable: bool, resolution: list[int] = [], format: maix.image.Format = ...) -> maix.err.Err

Set the snapshot parameters

item description
type func
note Enabling snapshot functionality may result in some performance loss.
param enable: enable or disable snapshot
resolution: image resolution of snapshot
format: image format of snapshot
return error code
static False

C++ defination code:

err::Err config_snapshot(bool enable, std::vector<int> resolution = std::vector<int>(), image::Format format = image::Format::FMT_YVU420SP)

config_resolution

def config_resolution(self, resolution: list[int]) -> maix.err.Err

Set the resolution of the video, and this API cannot be called during runtime.

item description
type func
note You must bind the camera first, and this interface will modify the camera's resolution. The width must be divisible by 32.
param resolution: The resolution of the video
return error code
static False

C++ defination code:

err::Err config_resolution(std::vector<int> resolution)

get_resolution

def get_resolution(self) -> list[int]

Get the resolution of the video

item description
type func
return the resolution of the video
static False

C++ defination code:

std::vector<int> get_resolution()

config_fps

def config_fps(self, fps: int) -> maix.err.Err

Set the fps of the video, and this API cannot be called during runtime.

item description
type func
note This interface only affect the fps of the encoded file.
return error code
static False

C++ defination code:

err::Err config_fps(int fps)

get_fps

def get_fps(self) -> int

Get the fps of the video.

item description
type func
return fps value
static False

C++ defination code:

int get_fps()

config_bitrate

def config_bitrate(self, bitrate: int) -> maix.err.Err

Set the bitrate of the video, and this API cannot be called during runtime.

item description
type func
return error code
static False

C++ defination code:

err::Err config_bitrate(int bitrate)

get_bitrate

def get_bitrate(self) -> int

Get the bitrate of the video.

item description
type func
return bitrate value
static False

C++ defination code:

int get_bitrate()

mute

def mute(self, data: int = -1) -> int

Set/Get the mute of the video

item description
type func
param data: If the parameter is true, mute; if false, unmute; if no parameter is provided, return the mute status.
return error code
static False

C++ defination code:

int mute(int data = -1)

volume

def volume(self, data: int = -1) -> int

Set/Get the volume of the video

item description
type func
param data: The volume of the video, the range is 0-100. if no parameter is provided, return the volume.
return error code
static False

C++ defination code:

int volume(int data = -1)

seek

def seek(self) -> int

Get the current position of the video

item description
type func
return current position, unit: ms
static False

C++ defination code:

int64_t seek()

record_start

def record_start(self) -> maix.err.Err

Start recording

item description
type func
note You must bind the camera at a minimum during input. Additionally,
if you bind a display, the input image will be shown,
if you bind a audio, audio will be recorded,
if you bind a IMU, IMU data will be logged.
return error code
static False

C++ defination code:

err::Err record_start()

snapshot

def snapshot(self) -> maix.image.Image

Take a snapshot

item description
type func
return image::Image
static False

C++ defination code:

image::Image *snapshot()

record_finish

def record_finish(self) -> maix.err.Err

Stop recording and save the video

item description
type func
return error code
static False

C++ defination code:

err::Err record_finish()

draw_rect

def draw_rect(self, id: int, x: int, y: int, w: int, h: int, color: maix.image.Color = ..., thickness: int = -1, hidden: bool = False) -> maix.err.Err

Draw a rect on the video

item description
type func
param id: id of the rect, range is [0, 15]
x: x coordinate
y: y coordinate
w: width
h: height
color: color
tickness: The line width of the rectangular box; if set to -1, it indicates that the rectangular box will be filled.
hidden: Hide or show the rectangular box
return error code
static False

C++ defination code:

err::Err draw_rect(int id, int x, int y, int w, int h, image::Color color = image::COLOR_WHITE, int thickness = -1, bool hidden = false)