Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
I
ils-common-video
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
提交
议题看板
打开侧边栏
OpsTeam
ils-common-video
Commits
30b4da73
提交
30b4da73
authored
7月 05, 2021
作者:
zw.wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: [recorder] 修改线程日志
上级
53d54e88
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
15 行增加
和
11 行删除
+15
-11
recorder.py
isc_video_record/recorder.py
+7
-5
isc_client.py
isc_video_record/utils/isc_client.py
+2
-1
pre_event.py
isc_video_record/utils/pre_event.py
+1
-0
setup.py
setup.py
+1
-1
test_playback.py
tests/test_playback.py
+4
-4
没有找到文件。
isc_video_record/recorder.py
浏览文件 @
30b4da73
...
...
@@ -66,7 +66,7 @@ class StreamRecorder:
ack
=
process_message
.
process
()
else
:
log
.
info
(
'camera_code[
%
s] processing, end.'
,
thread_id
,
body
[
'camera_code'
])
log
.
info
(
'camera_code[
%
s] processing, end.'
,
body
[
'camera_code'
])
except
Exception
as
e
:
log
.
exception
(
e
)
...
...
@@ -152,7 +152,7 @@ class ProcessMessage:
if
_continue
:
# 续约成功,本次任务继续
# 判定当前分布式锁是本线程设置的
log
.
info
(
'
%
s
:
%
s
,ttl:
%
s'
,
self
.
camera_key
,
pipe
.
ttl
(
self
.
camera_key
))
log
.
info
(
'
%
s,ttl:
%
s'
,
self
.
camera_key
,
pipe
.
ttl
(
self
.
camera_key
))
mysql
.
update_video_info
(
self
.
body
[
'db_table'
],
event
[
'video_id'
],
status
=
0
)
self
.
recording
(
event
)
else
:
...
...
@@ -237,7 +237,7 @@ class ProcessMessage:
log
.
info
(
'
%
s:
%
s is completed.'
,
event
[
'camera_code'
],
record_result
[
'file_name'
])
status
=
1
else
:
next_retry_time
=
now
+
timedelta
(
minutes
=
3
0
)
next_retry_time
=
now
+
timedelta
(
minutes
=
1
0
)
retry_count
+=
1
if
(
next_retry_time
-
event
[
'start_time'
])
>
timedelta
(
days
=
3
):
# 重试最长时间为3天
...
...
@@ -287,6 +287,7 @@ class ProcessMessage:
except
Exception
as
e
:
log
.
exception
(
e
)
res
.
update
({
'except'
:
True
,
'remark'
:
e
.
__str__
()})
send_alarm_to_developer
(
'recorder-{}'
.
format
(
self
.
thread_id
),
e
)
log
.
info
(
'
%
s: playback:
%
s'
,
self
.
body
[
'camera_code'
],
playback_urls
)
if
playback_urls
:
...
...
@@ -313,8 +314,8 @@ class ProcessMessage:
file_duration
=
time_to_seconds
(
file_info
[
'duration'
])
if
not
os
.
path
.
isfile
(
file_info
[
'file_name'
]):
retry_count
=
4
log
.
info
(
'当前录制无文件输出:
%
s, 重试计数:
%
s'
,
self
.
body
[
'camera_code'
],
retry_count
)
time
.
sleep
(
5
)
elif
file_duration
<
complete_duration
-
2
:
# 视频文件时长小于完整时长
new_start_time
=
start_time
+
timedelta
(
seconds
=
file_duration
)
...
...
@@ -343,7 +344,8 @@ class ProcessMessage:
concat
(
part_files
,
file_name
,
removed
=
True
)
elif
len
(
part_files
)
==
1
:
shutil
.
move
(
part_files
[
0
],
file_name
)
log
.
info
(
'
%
s: The download is complete, file
%
s'
,
self
.
body
[
'camera_code'
],
file_name
)
log
.
info
(
'
%
s: The download is complete, file
%
s, is_completed:
%
s'
,
self
.
body
[
'camera_code'
],
file_name
,
is_completed
)
res
.
update
({
'file_name'
:
file_name
,
'is_completed'
:
is_completed
,
...
...
isc_video_record/utils/isc_client.py
浏览文件 @
30b4da73
...
...
@@ -128,7 +128,8 @@ class HikVisionClient(object):
'endTime'
:
end_time
,
'recordLocation'
:
1
,
'protocol'
:
protocol
,
'expand'
:
'transcode=1&fileSize=1024&videotype=h264'
,
'expand'
:
'fileSize=1024'
,
# 'expand': 'transcode=1&fileSize=1024&videotype=h264',
'streamform'
:
streamform
,
}
log
.
info
(
'requests body: {}'
.
format
(
body
))
...
...
isc_video_record/utils/pre_event.py
浏览文件 @
30b4da73
...
...
@@ -24,6 +24,7 @@ class PreEvent(object):
where
$start_time <= time and time < $end_time
and camera_index = $camera_index
and event_type = '131331'
order by time
'''
res
=
influxdb
.
query
(
sql
,
bind_params
=
{
...
...
setup.py
浏览文件 @
30b4da73
...
...
@@ -24,7 +24,7 @@ requires = [
setuptools
.
setup
(
name
=
'isc-video-record'
,
version
=
'1.0.0b1
1
'
,
version
=
'1.0.0b1
2
'
,
description
=
'ISC motion detection playback video stream recording service.'
,
long_description
=
long_description
,
long_description_content_type
=
'text/markdown'
,
...
...
tests/test_playback.py
浏览文件 @
30b4da73
...
...
@@ -23,10 +23,10 @@ client = HikVisionClient(config.get('KEY'), config.get('SECRET'),
def
main
():
start_time
=
datetime
(
2021
,
6
,
30
,
18
,
58
,
29
)
.
astimezone
(
tz
)
start_time
=
datetime
(
2021
,
7
,
1
,
15
,
58
,
29
)
.
astimezone
(
tz
)
# start_time = datetime(2021, 5, 28, 9, 10, 59).astimezone(tz)
end_time
=
datetime
(
2021
,
6
,
30
,
18
,
59
,
0
)
.
astimezone
(
tz
)
camera_index
=
'
be03d4d8b12344a9adc92bfbf11fef53
'
end_time
=
datetime
(
2021
,
7
,
1
,
15
,
59
,
0
)
.
astimezone
(
tz
)
camera_index
=
'
5c8d0e1d572a4904a2c753ec24dfdf41
'
results
=
[]
try
:
...
...
@@ -53,7 +53,7 @@ def main():
else
:
print
(
res
)
for
event
in
res
:
for
event
in
res
ults
:
cur_start_time
=
max
(
event
[
'start_time'
],
start_time
)
cur_end_time
=
min
(
event
[
'end_time'
],
end_time
)
print
(
cur_start_time
,
cur_end_time
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论