Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
I
ils-common-video
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
提交
议题看板
打开侧边栏
OpsTeam
ils-common-video
Commits
100610b8
提交
100610b8
authored
4月 26, 2021
作者:
zw.wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: influxdb 保留策略和ffmpeg日志
上级
2540f8af
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
10 行增加
和
51 行删除
+10
-51
app.py
hikvision_isc_client/app.py
+1
-1
db.py
hikvision_isc_client/db.py
+3
-2
record.py
hikvision_isc_client/record.py
+6
-48
没有找到文件。
hikvision_isc_client/app.py
浏览文件 @
100610b8
...
@@ -35,7 +35,7 @@ def event_rcv():
...
@@ -35,7 +35,7 @@ def event_rcv():
'time'
:
dateutil
.
parser
.
parse
(
event
[
'happenTime'
])
'time'
:
dateutil
.
parser
.
parse
(
event
[
'happenTime'
])
})
})
influxdb
.
write_points
(
events
)
influxdb
.
write_points
(
events
,
retention_policy
=
'one_week'
)
return
jsonify
({
return
jsonify
({
'code'
:
200
'code'
:
200
...
...
hikvision_isc_client/db.py
浏览文件 @
100610b8
...
@@ -30,11 +30,12 @@ class InfluxDB(object):
...
@@ -30,11 +30,12 @@ class InfluxDB(object):
def
query
(
self
,
query_string
):
def
query
(
self
,
query_string
):
return
self
.
_influxdb
.
query
(
query_string
)
return
self
.
_influxdb
.
query
(
query_string
)
def
write_points
(
self
,
points
):
def
write_points
(
self
,
points
,
retention_policy
=
None
):
if
not
points
:
if
not
points
:
return
return
return
self
.
_influxdb
.
write_points
(
points
)
return
self
.
_influxdb
.
write_points
(
points
,
retention_policy
=
retention_policy
)
def
create_database
(
self
,
database
=
None
):
def
create_database
(
self
,
database
=
None
):
if
not
database
:
if
not
database
:
...
...
hikvision_isc_client/record.py
浏览文件 @
100610b8
...
@@ -3,51 +3,6 @@ import subprocess
...
@@ -3,51 +3,6 @@ import subprocess
from
intelab_python_sdk.logger
import
log
from
intelab_python_sdk.logger
import
log
class
RecordThread
:
def
__init__
(
self
,
stream
):
self
.
stream
=
stream
self
.
shell
=
[
'ffmpeg'
,
'-y'
,
'-v'
,
'info'
,
'-i'
,
'-'
,
'-c'
,
'copy'
,
'-f'
,
'mp4'
]
def
run
(
self
,
stream_url
,
out_file
):
log_buffer
=
''
cmd
=
self
.
shell
+
[
out_file
]
process
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
)
out
,
err
=
process
.
communicate
(
stream_url
)
return_code
=
process
.
poll
()
while
return_code
is
None
:
line
=
process
.
stdout
.
readline
(
81
)
log_buffer
+=
line
.
decode
()
# 换行打印日志
if
r'\n'
in
str
(
line
)
or
r'\r'
in
str
(
line
):
# 处理日志中\r的超过81字符的日志长度
log_buffer
=
log_buffer
.
split
(
'
\r
'
)
if
len
(
log_buffer
)
>
1
:
log_buffer
,
stdout
=
'
\n
'
.
join
(
log_buffer
[:
-
1
]),
log_buffer
[
-
1
]
else
:
log_buffer
=
''
.
join
(
log_buffer
)
stdout
=
''
if
'Non-monotonous DTS'
in
log_buffer
:
# 屏蔽日志中'Non-monotonous DTS in output stream:' 的告警信息
log_buffer
=
''
log
.
debug
(
'log:
%
s'
,
log_buffer
)
log_buffer
=
stdout
return_code
=
process
.
poll
()
return
out_file
def
record_thread
(
stream_url
,
out_file
):
def
record_thread
(
stream_url
,
out_file
):
cmd
=
[
cmd
=
[
...
@@ -62,7 +17,9 @@ def record_thread(stream_url, out_file):
...
@@ -62,7 +17,9 @@ def record_thread(stream_url, out_file):
]
]
log_buffer
=
''
log_buffer
=
''
process
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stdin
=
None
)
process
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stdin
=
None
,
stderr
=
subprocess
.
STDOUT
)
return_code
=
process
.
poll
()
return_code
=
process
.
poll
()
while
return_code
is
None
:
while
return_code
is
None
:
line
=
process
.
stdout
.
readline
(
81
)
line
=
process
.
stdout
.
readline
(
81
)
...
@@ -77,11 +34,12 @@ def record_thread(stream_url, out_file):
...
@@ -77,11 +34,12 @@ def record_thread(stream_url, out_file):
else
:
else
:
log_buffer
=
''
.
join
(
log_buffer
)
log_buffer
=
''
.
join
(
log_buffer
)
stdout
=
''
stdout
=
''
if
'
Non-monotonous
DTS'
in
log_buffer
:
if
'DTS'
in
log_buffer
:
# 屏蔽日志中'Non-monotonous DTS in output stream:' 的告警信息
# 屏蔽日志中'Non-monotonous DTS in output stream:' 的告警信息
log_buffer
=
''
log_buffer
=
''
if
log_buffer
:
log
.
debug
(
'ffmpeg-log:
%
s'
,
log_buffer
.
strip
())
log
.
debug
(
'ffmpeg-log:
%
s'
,
log_buffer
)
log_buffer
=
stdout
log_buffer
=
stdout
return_code
=
process
.
poll
()
return_code
=
process
.
poll
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论