save something
This commit is contained in:
parent
d3a295872c
commit
57955b5964
@ -48,7 +48,8 @@ async def run_ffmpeg(cam: int, channel: int):
|
|||||||
else:
|
else:
|
||||||
debug_args = ['-nostats', '-loglevel', 'error']
|
debug_args = ['-nostats', '-loglevel', 'error']
|
||||||
|
|
||||||
protocol = 'tcp' if ipcam_config.should_use_tcp_for_rtsp(cam) else 'udp'
|
# protocol = 'tcp' if ipcam_config.should_use_tcp_for_rtsp(cam) else 'udp'
|
||||||
|
protocol = 'tcp'
|
||||||
user, pw = ipcam_config.get_rtsp_creds()
|
user, pw = ipcam_config.get_rtsp_creds()
|
||||||
ip = ipcam_config.get_camera_ip(cam)
|
ip = ipcam_config.get_camera_ip(cam)
|
||||||
path = ipcam_config.get_camera_type(cam).get_channel_url(channel)
|
path = ipcam_config.get_camera_type(cam).get_channel_url(channel)
|
||||||
|
@ -23,17 +23,13 @@ class IpcamConfig(ConfigUnit):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def schema(cls) -> Optional[dict]:
|
def schema(cls) -> Optional[dict]:
|
||||||
return {
|
return {
|
||||||
'cams': {
|
'cameras': {
|
||||||
'type': 'dict',
|
'type': 'dict',
|
||||||
'keysrules': {'type': ['string', 'integer']},
|
'keysrules': {'type': ['string', 'integer']},
|
||||||
'valuesrules': {
|
'valuesrules': {
|
||||||
'type': 'dict',
|
'type': 'dict',
|
||||||
'schema': {
|
'schema': {
|
||||||
'type': {'type': 'string', 'allowed': [t.value for t in CameraType], 'required': True},
|
'type': {'type': 'string', 'allowed': [t.value for t in CameraType], 'required': True},
|
||||||
'codec': {'type': 'string', 'allowed': [t.value for t in VideoCodecType], 'required': True},
|
|
||||||
'container': {'type': 'string', 'allowed': [t.value for t in VideoContainerType], 'required': True},
|
|
||||||
'server': {'type': 'string', 'allowed': list(_lbc.get().keys()), 'required': True},
|
|
||||||
'disk': {'type': 'integer', 'required': True},
|
|
||||||
'motion': {
|
'motion': {
|
||||||
'type': 'dict',
|
'type': 'dict',
|
||||||
'schema': {
|
'schema': {
|
||||||
@ -44,10 +40,18 @@ class IpcamConfig(ConfigUnit):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'rtsp_tcp': {'type': 'boolean'}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'areas': {
|
||||||
|
'type': 'dict',
|
||||||
|
'keysrules': {'type': 'string'},
|
||||||
|
'valuesrules': {
|
||||||
|
'type': 'list',
|
||||||
|
'schema': {'type': ['string', 'integer']} # same type as for 'cameras' keysrules
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'camera_ip_template': {'type': 'string', 'required': True},
|
||||||
'motion_padding': {'type': 'integer', 'required': True},
|
'motion_padding': {'type': 'integer', 'required': True},
|
||||||
'motion_telegram': {'type': 'boolean', 'required': True},
|
'motion_telegram': {'type': 'boolean', 'required': True},
|
||||||
'fix_interval': {'type': 'integer', 'required': True},
|
'fix_interval': {'type': 'integer', 'required': True},
|
||||||
@ -94,6 +98,7 @@ class IpcamConfig(ConfigUnit):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# FIXME
|
||||||
def get_all_cam_names(self,
|
def get_all_cam_names(self,
|
||||||
filter_by_server: Optional[str] = None,
|
filter_by_server: Optional[str] = None,
|
||||||
filter_by_disk: Optional[int] = None) -> list[int]:
|
filter_by_disk: Optional[int] = None) -> list[int]:
|
||||||
@ -106,25 +111,22 @@ class IpcamConfig(ConfigUnit):
|
|||||||
cams.append(int(cam))
|
cams.append(int(cam))
|
||||||
return cams
|
return cams
|
||||||
|
|
||||||
def get_all_cam_names_for_this_server(self,
|
# def get_all_cam_names_for_this_server(self,
|
||||||
filter_by_disk: Optional[int] = None):
|
# filter_by_disk: Optional[int] = None):
|
||||||
return self.get_all_cam_names(filter_by_server=socket.gethostname(),
|
# return self.get_all_cam_names(filter_by_server=socket.gethostname(),
|
||||||
filter_by_disk=filter_by_disk)
|
# filter_by_disk=filter_by_disk)
|
||||||
|
|
||||||
def get_cam_server_and_disk(self, cam: int) -> tuple[str, int]:
|
# def get_cam_server_and_disk(self, cam: int) -> tuple[str, int]:
|
||||||
return self['cams'][cam]['server'], self['cams'][cam]['disk']
|
# return self['cams'][cam]['server'], self['cams'][cam]['disk']
|
||||||
|
|
||||||
def get_camera_container(self, cam: int) -> VideoContainerType:
|
def get_camera_container(self, camera: int) -> VideoContainerType:
|
||||||
return VideoContainerType(self['cams'][cam]['container'])
|
return self.get_camera_type(camera).get_container()
|
||||||
|
|
||||||
def get_camera_type(self, cam: int) -> CameraType:
|
def get_camera_type(self, camera: int) -> CameraType:
|
||||||
return CameraType(self['cams'][cam]['type'])
|
return CameraType(self['cams'][camera]['type'])
|
||||||
|
|
||||||
def get_rtsp_creds(self) -> tuple[str, str]:
|
def get_rtsp_creds(self) -> tuple[str, str]:
|
||||||
return self['rtsp_creds']['login'], self['rtsp_creds']['password']
|
return self['rtsp_creds']['login'], self['rtsp_creds']['password']
|
||||||
|
|
||||||
def should_use_tcp_for_rtsp(self, cam: int) -> bool:
|
|
||||||
return 'rtsp_tcp' in self['cams'][cam] and self['cams'][cam]['rtsp_tcp']
|
|
||||||
|
|
||||||
def get_camera_ip(self, camera: int) -> str:
|
def get_camera_ip(self, camera: int) -> str:
|
||||||
return f'192.168.5.{camera}'
|
return self['camera_ip_template'] % (str(camera),)
|
||||||
|
@ -1,25 +1,6 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
class CameraType(Enum):
|
|
||||||
ESP32 = 'esp32'
|
|
||||||
ALIEXPRESS_NONAME = 'ali'
|
|
||||||
HIKVISION = 'hik'
|
|
||||||
|
|
||||||
def get_channel_url(self, channel: int) -> str:
|
|
||||||
if channel not in (1, 2):
|
|
||||||
raise ValueError(f'channel {channel} is invalid')
|
|
||||||
if channel == 1:
|
|
||||||
return ''
|
|
||||||
elif channel == 2:
|
|
||||||
if self.value == CameraType.HIKVISION:
|
|
||||||
return '/Streaming/Channels/2'
|
|
||||||
elif self.value == CameraType.ALIEXPRESS_NONAME:
|
|
||||||
return '/?stream=1.sdp'
|
|
||||||
else:
|
|
||||||
raise ValueError(f'unsupported camera type {self.value}')
|
|
||||||
|
|
||||||
|
|
||||||
class VideoContainerType(Enum):
|
class VideoContainerType(Enum):
|
||||||
MP4 = 'mp4'
|
MP4 = 'mp4'
|
||||||
MOV = 'mov'
|
MOV = 'mov'
|
||||||
@ -30,6 +11,37 @@ class VideoCodecType(Enum):
|
|||||||
H265 = 'h265'
|
H265 = 'h265'
|
||||||
|
|
||||||
|
|
||||||
|
class CameraType(Enum):
|
||||||
|
ESP32 = 'esp32'
|
||||||
|
ALIEXPRESS_NONAME = 'ali'
|
||||||
|
HIKVISION_264 = 'hik_264'
|
||||||
|
HIKVISION_265 = 'hik_265'
|
||||||
|
|
||||||
|
def get_channel_url(self, channel: int) -> str:
|
||||||
|
if channel not in (1, 2):
|
||||||
|
raise ValueError(f'channel {channel} is invalid')
|
||||||
|
if channel == 1:
|
||||||
|
return ''
|
||||||
|
elif channel == 2:
|
||||||
|
if self.value in (CameraType.HIKVISION_264, CameraType.HIKVISION_265):
|
||||||
|
return '/Streaming/Channels/2'
|
||||||
|
elif self.value == CameraType.ALIEXPRESS_NONAME:
|
||||||
|
return '/?stream=1.sdp'
|
||||||
|
else:
|
||||||
|
raise ValueError(f'unsupported camera type {self.value}')
|
||||||
|
|
||||||
|
def get_codec(self, channel: int) -> VideoCodecType:
|
||||||
|
if channel == 1:
|
||||||
|
return VideoCodecType.H264 if self.value == CameraType.HIKVISION_264 else VideoCodecType.H265
|
||||||
|
elif channel == 2:
|
||||||
|
return VideoCodecType.H265 if self.value == CameraType.ALIEXPRESS_NONAME else VideoCodecType.H264
|
||||||
|
else:
|
||||||
|
raise ValueError(f'unexpected channel {channel}')
|
||||||
|
|
||||||
|
def get_container(self) -> VideoContainerType:
|
||||||
|
return VideoContainerType.MP4 if self.get_codec(1) == VideoCodecType.H264 else VideoContainerType.MOV
|
||||||
|
|
||||||
|
|
||||||
class TimeFilterType(Enum):
|
class TimeFilterType(Enum):
|
||||||
FIX = 'fix'
|
FIX = 'fix'
|
||||||
MOTION = 'motion'
|
MOTION = 'motion'
|
||||||
|
@ -6,7 +6,7 @@ Werkzeug==2.3.6
|
|||||||
uwsgi~=2.0.20
|
uwsgi~=2.0.20
|
||||||
python-telegram-bot==20.3
|
python-telegram-bot==20.3
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
aiohttp~=3.8.1
|
aiohttp~=3.9.1
|
||||||
pytz==2023.3
|
pytz==2023.3
|
||||||
PyYAML~=6.0
|
PyYAML~=6.0
|
||||||
apscheduler==3.10.1
|
apscheduler==3.10.1
|
||||||
|
2
tasks/df_h.sh
Normal file
2
tasks/df_h.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
df -h
|
Loading…
x
Reference in New Issue
Block a user