Updated on 2026-11-06 GMT+08:00

Videos

Video data is processed internally using PyAV.

  • Supported formats: MP4, MKV, WebM, AVI, MOV, FLV, M4V, M4A, 3GP, 3G2, and TS
  • Supported codecs: AVC1, AVC3, H.264, HVC1, H.265, HEVC, VP9, VP8, and MP4V

The video object includes specific attributes and methods for further processing.

Table 1 Attributes

Attribute

Type

Description

filename

str

Path of the video file (if loaded from a file).

format

str

Video format (e.g., mp4, avi).

data

bytes

Video data.

Table 2 Methods

Method

Parameter

Return Value

Description

__init__

filename: Union[str, os.PathLike] = None,data: Union[str, bytes] = None

None

Constructor: Loads video from a file or binary data.

truncate

start_time: float (start time, in seconds) <br>end_time: float (end time, in seconds) <br>shape: Optional[tuple[int, int]] (target resolution) <br>fps: float = None (target frame rate) <br>codec: str = "avc1" (encoding format) <br>format: str = "mp4" (output format)

Video

Trims a video segment, allowing adjustments to resolution, frame rate, and encoding format. Returns a new video object.

write

filename: str, codec: str

None

Saves the video to a file.

convert_format

format

Video

Converts the video to another one in a different format.