Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
I
ils-common-video
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
提交
议题看板
打开侧边栏
OpsTeam
ils-common-video
Commits
de89befd
提交
de89befd
authored
5月 18, 2021
作者:
zw.wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: [merger] 合并摄像头本地sd卡视频移动录制计划
上级
494adbbd
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
43 行增加
和
10 行删除
+43
-10
merger.py
isc_video_record/merger.py
+17
-2
api_helper.py
isc_video_record/utils/api_helper.py
+25
-7
setup.py
setup.py
+1
-1
没有找到文件。
isc_video_record/merger.py
浏览文件 @
de89befd
...
@@ -20,6 +20,9 @@ from isc_video_record.pre_event import PreEvent
...
@@ -20,6 +20,9 @@ from isc_video_record.pre_event import PreEvent
from
isc_video_record.db.mysql
import
get_camera_info
,
insert_video_info
from
isc_video_record.db.mysql
import
get_camera_info
,
insert_video_info
from
isc_video_record.utils.excel_utils
import
gen_excel
from
isc_video_record.utils.excel_utils
import
gen_excel
from
isc_video_record.utils.aliyun_oss
import
oss_upload_file
from
isc_video_record.utils.aliyun_oss
import
oss_upload_file
from
isc_video_record.utils.api_helper
import
IntelabApiHelper
api_helper
=
IntelabApiHelper
()
TIMEZONE
=
'Asia/Shanghai'
TIMEZONE
=
'Asia/Shanghai'
tz
=
pytz
.
timezone
(
TIMEZONE
)
tz
=
pytz
.
timezone
(
TIMEZONE
)
...
@@ -161,8 +164,20 @@ class EventMergerJob:
...
@@ -161,8 +164,20 @@ class EventMergerJob:
self
.
send_mq_message
(
body
)
self
.
send_mq_message
(
body
)
return
body
.
get
(
'ex'
,
0
)
return
body
.
get
(
'ex'
,
0
)
def
get_local_events
(
self
,
last_check_time
,
now
,
camera
):
"""
查询sd卡上移动侦测视频
"""
events
=
api_helper
.
get_cameras_playback_urls
(
camera
[
'device_code'
],
IntelabApiHelper
.
iso_format
(
last_check_time
),
IntelabApiHelper
.
iso_format
(
now
))
return
events
def
get_new_events
(
self
,
last_check_time
,
now
,
camera
):
def
get_new_events
(
self
,
last_check_time
,
now
,
camera
):
"""
"""
摄像头录制计划为全天录制时
查询指定时间段内摄像头是否有移动告警消息并合并成事件
查询指定时间段内摄像头是否有移动告警消息并合并成事件
"""
"""
pre_event
=
PreEvent
(
pre_event
=
PreEvent
(
...
@@ -198,7 +213,7 @@ class EventMergerJob:
...
@@ -198,7 +213,7 @@ class EventMergerJob:
event_duration
=
0
event_duration
=
0
for
event
in
self
.
get_
new
_events
(
last_check_time
,
now
,
camera
):
for
event
in
self
.
get_
local
_events
(
last_check_time
,
now
,
camera
):
insert_video_info
(
insert_video_info
(
camera
[
'db_table'
],
camera
[
'device_code'
],
camera
[
'db_table'
],
camera
[
'device_code'
],
event
[
'start_time'
]
.
astimezone
(
pytz
.
utc
),
event
[
'start_time'
]
.
astimezone
(
pytz
.
utc
),
...
@@ -225,7 +240,7 @@ class EventMergerJob:
...
@@ -225,7 +240,7 @@ class EventMergerJob:
try
:
try
:
camera_event_duration
=
self
.
process_camera
(
pipe
,
camera
)
camera_event_duration
=
self
.
process_camera
(
pipe
,
camera
)
total_video_duration
+=
camera_event_duration
total_video_duration
+=
camera_event_duration
if
camera_event_duration
>
0
:
if
camera_event_duration
>
1
0
:
camera_count
+=
1
camera_count
+=
1
except
Exception
as
e
:
except
Exception
as
e
:
...
...
isc_video_record/utils/api_helper.py
浏览文件 @
de89befd
...
@@ -28,12 +28,31 @@ class IntelabApiHelper:
...
@@ -28,12 +28,31 @@ class IntelabApiHelper:
res_json
=
response
.
json
()
.
get
(
'data'
)
or
{}
res_json
=
response
.
json
()
.
get
(
'data'
)
or
{}
# TODO 数据为空的异常处理
# TODO 数据为空的异常处理
results
=
[]
for
f
in
res_json
.
get
(
'list'
)
or
[]:
start_time
=
dateutil
.
parser
.
parse
(
f
[
'beginTime'
])
end_time
=
dateutil
.
parser
.
parse
(
f
[
'endTime'
])
results
.
append
({
pre_events
=
res_json
.
get
(
'list'
)
or
[]
events
=
[]
if
len
(
pre_events
)
>
0
:
events
.
append
({
'start_time'
:
dateutil
.
parser
.
parse
(
pre_events
[
0
][
'beginTime'
]),
'end_time'
:
dateutil
.
parser
.
parse
(
pre_events
[
0
][
'endTime'
]),
'expired_time'
:
expired_time
,
'stream_url'
:
{
'url'
:
res_json
.
get
(
'url'
),
'extra_args'
:
'playBackMode=1'
,
'protocol'
:
protocol
}
})
for
pre_event
in
pre_events
[
1
:]:
# 合并时间间隔较短的事件
last_end_time
=
events
[
-
1
][
'end_time'
]
start_time
=
dateutil
.
parser
.
parse
(
pre_events
[
'beginTime'
])
end_time
=
dateutil
.
parser
.
parse
(
pre_events
[
'endTime'
])
if
start_time
-
last_end_time
<=
timedelta
(
seconds
=
2
):
events
[
-
1
][
'end_time'
]
=
end_time
else
:
events
.
append
({
'start_time'
:
start_time
,
'start_time'
:
start_time
,
'end_time'
:
end_time
,
'end_time'
:
end_time
,
'expired_time'
:
expired_time
,
'expired_time'
:
expired_time
,
...
@@ -42,10 +61,9 @@ class IntelabApiHelper:
...
@@ -42,10 +61,9 @@ class IntelabApiHelper:
'extra_args'
:
'playBackMode=1'
,
'extra_args'
:
'playBackMode=1'
,
'protocol'
:
protocol
'protocol'
:
protocol
}
}
})
})
return
resul
ts
return
even
ts
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
setup.py
浏览文件 @
de89befd
...
@@ -23,7 +23,7 @@ requires = [
...
@@ -23,7 +23,7 @@ requires = [
setuptools
.
setup
(
setuptools
.
setup
(
name
=
'isc-video-record'
,
name
=
'isc-video-record'
,
version
=
'1.0.0a1
6
'
,
version
=
'1.0.0a1
7
'
,
description
=
'ISC motion detection playback video stream recording service.'
,
description
=
'ISC motion detection playback video stream recording service.'
,
long_description
=
long_description
,
long_description
=
long_description
,
long_description_content_type
=
'text/markdown'
,
long_description_content_type
=
'text/markdown'
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论