Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
I
ils-common-video
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
提交
议题看板
打开侧边栏
OpsTeam
ils-common-video
Commits
d4a61efc
提交
d4a61efc
authored
5月 04, 2021
作者:
zw.wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 修复时区问题
上级
51a90c5b
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
25 行增加
和
21 行删除
+25
-21
client.py
hikvision_isc_client/client.py
+1
-1
const.py
hikvision_isc_client/const.py
+1
-1
merger.py
hikvision_isc_client/merger.py
+15
-15
recorder.py
hikvision_isc_client/recorder.py
+4
-3
record_utils.py
hikvision_isc_client/utils/record_utils.py
+4
-1
没有找到文件。
hikvision_isc_client/client.py
浏览文件 @
d4a61efc
...
...
@@ -130,7 +130,7 @@ class HikVisionClient(object):
'expand'
:
'fileSize=1024'
,
'streamform'
:
streamform
}
print
(
'
Body:
%
s'
,
body
)
print
(
'
requests body: {}'
.
format
(
body
)
)
expired_time
=
datetime
.
now
()
+
timedelta
(
minutes
=
5
)
res
=
self
.
_request
(
uri
,
body
)
results
=
[]
...
...
hikvision_isc_client/const.py
浏览文件 @
d4a61efc
LAST_CHECK_TIME_KEY
=
'isc:recorder:camera:{}'
LAST_CHECK_TIME_KEY
=
'
hk_
isc:recorder:camera:{}'
hikvision_isc_client/merger.py
浏览文件 @
d4a61efc
import
pytz
import
json
import
time
import
dateutil.parser
from
datetime
import
datetime
,
timedelta
from
intelab_python_sdk.logger
import
log
from
hikvision_isc_client.db
import
influxdb
,
rabbitmq_connect
,
redis_connect
from
hikvision_isc_client.db
import
rabbitmq_connect
,
redis_connect
from
hikvision_isc_client.const
import
LAST_CHECK_TIME_KEY
from
hikvision_isc_client.pre_event
import
PreEvent
...
...
@@ -49,29 +48,30 @@ class EventMergerJob:
pipe
=
redis_connect
()
for
camera
in
get_camera_info
():
now
_std
=
datetime
.
now
(
pytz
.
timezone
(
'Asia/Shanghai'
)
)
now
=
datetime
.
utcnow
(
)
camera_code
=
camera
[
'device_code'
]
last_check_time_key
=
LAST_CHECK_TIME_KEY
.
format
(
camera_code
)
last_check_time
=
pipe
.
get
(
last_check_time_key
)
if
not
last_check_time
:
# 设备无上次事件,取最近的15分钟作为开始时间
last_check_time
=
now
_std
-
timedelta
(
minutes
=
15
)
last_check_time
=
now
-
timedelta
(
minutes
=
15
)
else
:
last_check_time
=
dateutil
.
parser
.
parse
(
last_check_time
)
.
astimezone
(
tz
)
last_check_time
=
datetime
.
strptime
(
last_check_time
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
# 调整最大事件长度为1天
if
now
_std
-
last_check_time
>
timedelta
(
days
=
1
):
last_check_time
=
now
_std
-
timedelta
(
days
=
1
)
if
now
-
last_check_time
>
timedelta
(
days
=
1
):
last_check_time
=
now
-
timedelta
(
days
=
1
)
res
=
pipe
.
set
(
last_check_time_key
,
now
_std
.
astimezone
(
pytz
.
utc
)
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
))
now
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
))
if
not
res
:
continue
pre_event
=
PreEvent
(
last_check_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
),
now_std
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
))
alarm_list
=
pre_event
.
get_alarm_list
(
camera
[
'index_code'
])
log
.
info
(
'time: {}-{}, alarm_list: {}'
.
format
(
last_check_time
,
now_std
,
len
(
alarm_list
)))
pre_event
=
PreEvent
(
last_check_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
),
now
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
)
alarm_list
=
list
(
pre_event
.
get_alarm_list
(
camera
[
'index_code'
]))
log
.
info
(
'time: {}-{}, alarm_list: {}'
.
format
(
last_check_time
,
now
,
len
(
alarm_list
)))
connection
=
None
# if len(alarm_list) > 0:
connection
=
rabbitmq_connect
()
...
...
@@ -79,8 +79,8 @@ class EventMergerJob:
channel
.
queue_declare
(
self
.
queue_name
,
durable
=
True
)
# TODO 测试持续获取事件
events
=
[{
'start_time'
:
last_check_time
,
'end_time'
:
now_std
}]
#
events = PreEvent.merge_alarm_to_event(alarm_list)
#
events = [{'start_time': last_check_time, 'end_time': now_std}]
events
=
PreEvent
.
merge_alarm_to_event
(
alarm_list
)
for
event
in
events
:
body
=
{
...
...
hikvision_isc_client/recorder.py
浏览文件 @
d4a61efc
...
...
@@ -88,8 +88,9 @@ class StreamRecorder:
def
process_message
(
self
,
body
):
file_name
=
self
.
recorder
(
body
[
'camera_index'
],
datetime
.
strptime
(
body
[
'start_time'
],
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S'
),
datetime
.
strptime
(
body
[
'end_time'
],
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S'
))
datetime
.
strptime
(
body
[
'start_time'
],
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S'
)
.
astimezone
(
tz
),
datetime
.
strptime
(
body
[
'end_time'
],
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S'
)
.
astimezone
(
tz
)
)
video_info
=
get_video_duration
(
file_name
)
url
=
''
if
file_name
and
os
.
path
.
isfile
(
file_name
):
...
...
@@ -110,7 +111,6 @@ class StreamRecorder:
playback_stream
=
playback_urls
[
0
]
else
:
return
log
.
info
(
playback_stream
)
part_num
=
1
part_files_set
=
set
()
file_name
=
os
.
path
.
join
(
video_path
,
'rtmp_{}_{}.mp4'
.
format
(
...
...
@@ -163,6 +163,7 @@ class StreamRecorder:
end_time
,
stream
[
'extra_args'
])
file_name
=
os
.
path
.
join
(
video_path
,
'rtmp_{}_{}.mp4'
.
format
(
start_time
,
end_time
))
log
.
info
(
'stream_url:
%
s'
,
stream_url
)
record_thread
(
stream_url
,
file_name
)
return
get_video_duration
(
file_name
)
...
...
hikvision_isc_client/utils/record_utils.py
浏览文件 @
d4a61efc
...
...
@@ -37,7 +37,10 @@ def record_thread(stream_url, out_file):
if
'DTS'
in
log_buffer
:
# 屏蔽日志中'Non-monotonous DTS in output stream:' 的告警信息
log_buffer
=
''
if
log_buffer
:
if
log_buffer
and
'error'
in
log_buffer
:
log
.
error
(
'ffmpeg-log:error:
%
s'
,
log_buffer
.
strip
())
elif
log_buffer
:
log
.
debug
(
'ffmpeg-log:
%
s'
,
log_buffer
.
strip
())
log_buffer
=
stdout
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论