gb28181-docking-platform-proxy/test/video.py
2024-03-15 10:13:31 +08:00

45 lines
1.2 KiB
Python

import os.path as path
import sys
import shutil
work_path = sys.path[0]
# 设备列表
devices_file = "devices.txt"
devices_file_path = path.join(work_path, devices_file)
# 源文件
source_video_file = "20240311081115_20240311081130.mp4"
def check_or_create_devices_file():
if not path.exists(devices_file_path):
with open(devices_file_path, mode="w", encoding="utf8") as f:
f.write("# 设备编码 一行一个\n")
def read_devices_file():
check_or_create_devices_file()
devices = []
with open(devices_file_path, mode="r", encoding="utf8") as f:
while True:
line = f.readline()
if not line:
break
line = line.strip()
if line.startswith("#") or len(line) == 0:
continue
else:
devices.append(line)
print("读取设备数量: {}".format(len(devices)))
return devices
if __name__ == '__main__':
check_or_create_devices_file()
devices = read_devices_file()
src = path.join(work_path, source_video_file)
for device in devices:
dst = path.join(work_path, "{}_{}".format(device, source_video_file))
shutil.copyfile(src, dst)