英文 | 韩文 | 中文 | 日文

APIs: utils

获取频道列表

获取摄像机的频道列表。

🛠️ channels = get_channel_list()

↩️ channels: 包含频道信息的对象数组。每个对象包括以下属性:

🔹ch_no: 频道编号。

🔹title: 频道标题。

🔹is_connected: 指示摄像机是否已连接。

🔹is_recording: 指示摄像机是否正在录制。

🔹is_ptz: 指示摄像机是否为PTZ(云台变焦)摄像机。

🔹ptz_presets: PTZ预置位列表,其中"no"为预置位编号,"title"为预置位标题。

🔹date_start: 录制开始日期,字符串格式为 "yyyy-mm-dd"。

🔹date_end: 录制结束日期,字符串格式为 "yyyy-mm-dd"。

🔹sub_channel_count: 子频道数量。

utils = vmspy.utils()
if not utils.init(address, port, access_id, access_pw):
    print(utils.get_error())

channels = utils.get_channel_list()
for ch in channels:
    print("Ch No:", ch.ch_no)       # 1
    print("Title:", ch.title)       # "Channel Title"
    print("Sub Channels:", ch.sub_channel_count) # 0
    print("Connected:", ch.is_connected) # True/False
    print("Recording:", ch.is_recording) # True/False
    print("Start:", ch.date_start)  # "2025-04-01"
    print("End:", ch.date_end)      # "2025-04-17"
    print("PTZ:", ch.is_ptz)        # True
    for p in ch.ptz_presets:
        print("-Preset No:", p.no)        # 1
        print("-Preset Title:", p.title)  # "Preset#1"

 

获取组列表

获取组列表及其成员频道。

🛠️ groups = get_group_list()

↩️ groups: 包含组信息的对象数组。每个对象包括以下属性:

🔹group_idx: 组索引。

🔹title: 组标题。

🔹channels: 包含频道信息的对象数组。

🔹ch_no: 频道编号。

🔹title: 频道标题。

utils = vmspy.utils()
if not utils.init(address, port, access_id, access_pw):
    print(utils.get_error())

groups = utils.get_group_list()
print(group_list)

for gr in groups:
    print("Group index:", gr.idx)  # 0
    print("Title:", gr.title)     # "Group Title"
    for ch in gr.channels:
        print("- ch no:", ch.ch_no) # 1
        print("- title:", ch.title) # "Channel Title"

 

获取录制日期

获取指定月份的录制日期。

🛠️ dates = get_recording_dates(year, month)

➡️ year, month: 指定请求的月份。

↩️ dates: 对象数组。每个对象包括:

🔹ch_no: 频道编号。

🔹title: 频道标题。

🔹dates: 有录像的日期数组,例如:["2026-03-19", "2026-03-20"]。

utils = vmspy.utils()
if not utils.init(address, port, access_id, access_pw):
    print(utils.get_error())

recordingDates = utils.get_recording_dates(2026, 3)
for rcd in recordingDates:
    print("Channel No:", rcd.ch_no)     # 1
    print("Channel Title:", rcd.title)  # "Channel Title"
    for ds in rcd.dates:
        print("- Date:", ds)            # "2026-03-19"

 

获取录制时间

获取特定日期的录制时间。

🛠️ recording_times = get_recording_times(ch_no, year, month, day, sub_idx=0)

➡️ ch_no: 频道编号。

➡️ year, month, day: 指定请求的录制日期。

➡️ sub_idx: 频道子索引,0为主码流。

↩️ recording_times: 对象数组。每个对象包括以下属性:

🔹time: 以ISO-8601格式表示的录制开始时间。

🔹timestamp: 以Unix时间戳表示的录制开始时间。

🔹is_dst: 表示该时间是否为夏令时(DST)。

🔹duration: 录制的持续时间(秒)。

recordingTimes = utils.get_recording_times(1, 2025, 4, 18) # ch#1
for t in recordingTimes:
    print("Time:", t.time)            # 2026-03-20T11:22:45+09:00
    print("Timestamp:", t.timestamp)  # 1773973365
    print("DST:", t.is_dst)           # False
    print("Duration:", t.duration)    # 171

 

获取归档文件

获取归档文件列表。

🛠️ files = get_file_list()

↩️ files: 对象数组。每个对象包括以下属性:

🔹file_id: 文件ID。

🔹ch_no: 频道编号。

🔹title: 频道标题。

🔹time: ISO 8601格式的文件开始时间。

🔹timestamp: 以Unix时间戳表示的文件开始时间。

🔹is_dst: 表示该时间是否为夏令时(DST)。

🔹duration: 文件持续时间(秒)。

🔹priority: 文件优先级(0–5)。

🔹filesize: 文件大小。

utils = vmspy.utils()
if not utils.init(address, port, access_id, access_pw):
    print(utils.get_error())

files = utils.get_file_list()
for file in files:
    print("File ID:", file.file_id)     # 29513186
    print("Channel No:", file.ch_no)    # 1
    print("Channel Title:", file.title) # "Channel Title"
    print("Time:", file.time)           # 2026-02-11T15:23:17+09:00
    print("Timestamp:", file.timestamp) # 1770790997
    print("DST:", file.is_dst)         # False
    print("Duration:", file.duration)   # 16
    print("Priority:", file.priority)   # 0
    print("File size:", file.filesize)  # 11408614471

 

获取事件

获取特定日期和频道的事件。

🛠️ events = get_events(ch_no, year, month, day, num_days=1)

➡️ ch_no: 频道编号。如果设置为0,则检索所有频道的事件。

➡️ year, month, day: 指定请求的日期。

➡️ num_days: 指定要返回的天数(默认:1)。

↩️ events: 对象数组。每个对象包括以下属性:

🔹ch_no: 事件的频道编号。

🔹type: 事件类型。

🔹time: 事件时间(ISO-8601格式)。

🔹timestamp: 以Unix时间戳表示的事件时间。

🔹is_dst: 表示该时间是否为夏令时(DST)。

🔹duration: 事件持续时间(秒)。

utils = vmspy.utils()
if not utils.init(address, port, access_id, access_pw):
    print(utils.get_error())

events = utils.get_events(0, 2025, 4, 18, num_days=5) # 获取所有频道5天内的事件
for e in events:
    print("Channel No:", e.ch_no)     # 1
    print("Event Type:", e.type)      # "MOTION"
    print("Time:", e.time)            # 2026-03-20T11:22:45+09:00
    print("Timestamp:", e.timestamp)  # 1773973365
    print("DST:", e.is_dst)           # False
    print("Duration:", e.duration)    # 11

 

移动PTZ预置位置

将PTZ摄像机移动到指定的预置位置。

🛠️ ptz_preset_go(ch_no, preset_no)

➡️ ch_no: 频道编号。

➡️ preset_no: 要移动到的预置编号。

if not utils.ptz_preset_go(1, 3):
    print(utils.get_error())

 

获取PTZ预置位置

获取当前PTZ摄像机的预置位置。

🛠️ preset = get_ptz_preset(ch_no)

➡️ ch_no: 频道编号。

↩️ preset: 如果该频道未设置预置位置,则返回 `None`;否则返回包含以下属性的对象:

🔹no: 预置编号。

🔹title: 预置标题。

p = utils.get_ptz_preset(1)
if p == None:
    print("No prest position is set")
else:
    print(f"Preset position #{p.no}.{p.title} is set")

 

在VMS服务器中显示直播频道

在VMS服务器上显示频道的实时视频图像。

🛠️ show_live(ch_no, sub_idx=0)

➡️ ch_no: 频道编号。

➡️ sub_idx: 频道子索引,0为主码流。

if not utils.show_live(1):
    print(utils.get_error())

 

在VMS服务器中显示回放频道

在VMS服务器上指定时间显示频道的回放视频图像。

🛠️ show_playback(ch_no, year, month, day, hour, minute, second, sub_idx=0)

➡️ ch_no: 频道编号。

➡️ year, month, day: 指定回放日期。

➡️ hour, minute, second: 指定回放时间。

➡️ sub_idx: 频道子索引,0为主码流。

if not utils.show_playback(1, 2025, 4, 18, 14, 30, 0):
    print(utils.get_error())

 

在VMS服务器上显示组实时视频

在VMS服务器上显示指定组的实时视频图像。

🛠️ show_group_live(group_idx)

➡️ group_idx: 组索引。

# 在VMS中显示第一个组(group_idx=0)
if not utils.show_group_live(0):
    print(utils.get_error())

 

在VMS服务器上显示组回放

在VMS服务器上指定时间显示组的回放视频图像。

🛠️ show_group_playback(group_idx, year, month, day, hour, minute, second)

➡️ group_idx: 组索引。

➡️ year, month, day: 指定回放日期。

➡️ hour, minute, second: 指定回放时间。

# 在VMS中显示2025-04-18 14:30:00的第一个组(group_idx=0)
if not utils.show_group_playback(0, 2025, 4, 18, 14, 30, 0):
    print(utils.get_error())

 

在VMS服务器上显示归档文件回放

在VMS服务器上显示指定归档文件的回放视频图像。

🛠️ show_file_playback(file_id, timestamp)

➡️ file_id: 指定文件ID。

➡️ timestamp: 以Unix时间戳指定回放时间。

# 在VMS中以Unix时间戳1770790997显示归档文件(file_id=29513186)
if not utils.show_file_playback(29513186, 1770790997):
    print(utils.get_error())