Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
I
ils-common-video
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
提交
议题看板
打开侧边栏
OpsTeam
ils-common-video
Commits
3bd7a14b
提交
3bd7a14b
authored
8月 02, 2021
作者:
zw.wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: [eviz-recorder] 流录制方式支持海康的无法获取回放的摄像头
上级
4160e79b
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
62 行增加
和
17 行删除
+62
-17
mysql.py
ils_common_video/db/mysql.py
+23
-8
merger.py
ils_common_video/eviz_video/merger.py
+10
-1
pre_event.py
ils_common_video/eviz_video/pre_event.py
+1
-1
recorder.py
ils_common_video/eviz_video/recorder.py
+9
-5
api_helper.py
ils_common_video/utils/api_helper.py
+17
-0
video_file.py
ils_common_video/utils/video_file.py
+1
-1
setup.py
setup.py
+1
-1
没有找到文件。
ils_common_video/db/mysql.py
浏览文件 @
3bd7a14b
...
...
@@ -80,17 +80,32 @@ def query(cursor_dict=False):
@query
(
cursor_dict
=
True
)
def
get_camera_info
(
cursor
,
conn
,
camera_code
=
None
,
platform
=
'isc'
):
def
get_camera_info
(
cursor
,
conn
,
camera_code
=
None
,
platform
=
'isc'
,
video_plan_type
=
None
):
"""
:param cursor:
:param conn:
:param camera_code:
:param platform: 平台参数,默认为isc-海康安防平台; eviz-萤石云平台
:param video_plan_type: 默认为None,当海康的摄像头需要使用直播流录制时参数为-1
"""
if
camera_code
:
_filter
=
'where camera_info.device_code = "{}"'
.
format
(
camera_code
)
else
:
_filter
=
'''
where camera_info.platform = "{}"
and camera_info.is_valid = 1
and biz_type is not null
'''
.
format
(
platform
)
if
platform
==
'isc'
:
_filter
+=
' and `point_index_code` is not null '
# TODO 这里的查询需要后期优化
if
platform
==
'eviz'
and
video_plan_type
==
-
1
:
_filter
=
'''
where (camera_info.platform = "eviz" or video_plan_type = -1)
and camera_info.is_valid = 1
and biz_type is not null
'''
else
:
_filter
=
'''
where camera_info.platform = "{}"
and camera_info.is_valid = 1
and biz_type is not null
'''
.
format
(
platform
)
if
platform
==
'isc'
:
_filter
+=
' and `point_index_code` is not null '
sql
=
'''
select
...
...
ils_common_video/eviz_video/merger.py
浏览文件 @
3bd7a14b
...
...
@@ -98,7 +98,15 @@ def merger_events(camera_code, files):
try
:
log
.
info
(
'查询摄像头
%
s在
%
s到
%
s之间的移动事件'
,
camera_code
,
start_time
,
end_time
)
camera
,
events
=
pre_events
.
get_events
(
camera_code
)
# TODO 这里需要对海康接入的摄像头获取Influxdb事件
# TODO 目前是写死默认所有的视频,该几款摄像头无回调事件
if
camera
[
'platform'
]
==
'isc'
:
events
=
[{
'start_time'
:
start_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
),
'end_time'
:
end_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
}]
# insert_influxdb_events_info(camera_code, all_pre_files, events)
except
URLError
as
e
:
log
.
exception
(
e
)
...
...
@@ -119,7 +127,8 @@ def merger_events(camera_code, files):
# log.warning('事件过滤逻辑已经关闭')
# pre_files = all_pre_files
log
.
info
(
'共耗时
%
s秒,筛选预视频文件数:
%
s'
,
round
(
time
.
time
()
-
t
,
3
),
len
(
pre_files
))
log
.
info
(
'摄像头协议为
%
s, 共耗时
%
s秒,筛选预视频文件数:
%
s'
,
camera
[
'treaty'
],
round
(
time
.
time
()
-
t
,
3
),
len
(
pre_files
))
if
len
(
pre_files
)
<
1
:
return
...
...
ils_common_video/eviz_video/pre_event.py
浏览文件 @
3bd7a14b
...
...
@@ -88,10 +88,10 @@ class PreEvent:
def
get_events
(
self
,
camera_sn
):
log
.
info
(
'处理摄像头
%
s'
,
camera_sn
)
token
=
EvizVersionClient
.
get_access_token
(
camera_sn
)
camera
=
get_camera_info
(
camera_code
=
camera_sn
)
camera
=
camera
[
0
]
if
camera
else
None
token
=
EvizVersionClient
.
get_access_token
(
camera_sn
)
# 使用移动告警接口获取事件
alarm_list
=
self
.
get_alarm_list
(
token
,
camera_sn
)
channel
=
int
(
camera_sn
.
split
(
':'
,
1
)[
1
])
if
':'
in
camera_sn
else
1
...
...
ils_common_video/eviz_video/recorder.py
浏览文件 @
3bd7a14b
...
...
@@ -12,11 +12,13 @@ from intelab_python_sdk.ffmpeg.ffmpeg_record import FfmpegRecordThread
from
ils_common_video.db
import
mysql
,
redis
from
ils_common_video.db.influxdb
import
influxdb
from
ils_common_video.utils.eviz_client
import
EvizVersionClient
from
ils_common_video.utils.api_helper
import
IntelabApiHelper
# from intelab_video.ffmpeg.read_video_resolution import FfprobeThread
service_name
=
settings
.
get
(
'SERVICE_NAME'
,
''
)
TIMEZONE
=
'Asia/Shanghai'
tz
=
pytz
.
timezone
(
TIMEZONE
)
api_helper
=
IntelabApiHelper
()
class
VideoRecord
:
...
...
@@ -81,7 +83,8 @@ class VideoRecord:
# 判断视频是否使用高清流
# is_hd = True if VideoRecord.resolution_compare(camera['video_resolution'], '768x432') else False
is_hd
=
True
stream_url
=
VideoRecord
.
update_rtmp_stream
(
camera
[
'device_code'
],
stream_url
,
is_hd
=
is_hd
)
stream_url
=
api_helper
.
get_camera_stream_url
(
camera
[
'device_code'
],
stream_url
)
# stream_url = VideoRecord.update_rtmp_stream(camera['device_code'], stream_url, is_hd=is_hd)
# TODO rtmp直播流地址缓存到云端
# if stream_url:
...
...
@@ -93,7 +96,11 @@ class VideoRecord:
# last_time = datetime.now() - timedelta(minutes=8)
# offline_device_list = db.influxdb_client.get_devices_status(last_time, status=0)
for
camera_info
in
mysql
.
get_camera_info
(
platform
=
'eviz'
):
for
camera_info
in
mysql
.
get_camera_info
(
platform
=
'eviz'
,
video_plan_type
=-
1
):
# TODO 测试
if
camera_info
.
get
(
'platform'
)
==
'eviz'
:
continue
# TODO 离线的摄像头进行处理
# if camera_sn in offline_device_list:
# log.info('设备%s在此刻已经离线', camera_sn)
# db.influxdb_client.insert_restart_second(
...
...
@@ -105,9 +112,6 @@ class VideoRecord:
# 只有开启了云存储的才会启动录制服务
log
.
warning
(
'摄像头
%
s未开启云存储功能,不需要进行录制'
,
camera_info
[
'device_code'
])
continue
full_day
=
True
if
camera_info
[
'ai_config_support'
][
2
]
==
'1'
else
False
movement
=
True
if
camera_info
[
'ai_config_support'
][
3
]
==
'1'
else
False
sn_list
.
append
(
camera_info
[
'device_code'
])
rtmp_url
=
VideoRecord
.
update_video_stream
(
camera_info
,
camera_info
[
'video_stream_url'
])
...
...
ils_common_video/utils/api_helper.py
浏览文件 @
3bd7a14b
...
...
@@ -100,6 +100,23 @@ class IntelabApiHelper:
res_json
=
response
.
json
()
.
get
(
'data'
)
or
{}
return
res_json
def
get_camera_stream_url
(
self
,
camera_sn
,
stream_url
=
None
):
"""
更新摄像头直播地址
"""
url
=
'{}/python/api/v1/secure/camera/stream/{}?isRefresh=1'
.
format
(
self
.
host
,
camera_sn
)
try
:
res
=
requests
.
get
(
url
)
if
not
res
:
raise
ConnectionError
(
'error. {}'
.
format
(
url
))
res
=
res
.
json
()
except
Exception
as
e
:
log
.
exception
(
e
)
res
=
{
'data'
:
None
}
print
(
res
)
stream_url
=
res
.
get
(
'data'
)
if
res
.
get
(
'data'
)
else
stream_url
return
stream_url
if
__name__
==
'__main__'
:
api_helper
=
IntelabApiHelper
()
...
...
ils_common_video/utils/video_file.py
浏览文件 @
3bd7a14b
...
...
@@ -159,7 +159,7 @@ class VideoFile:
elements
=
[
prefix
,
camera_code
,
start_time
.
strftime
(
'
%
Y
%
m
%
dT
%
H
%
M
%
S'
),
end_time
.
strftime
(
'
%
Y
%
m
%
d
%
H
%
M
%
S'
)
end_time
.
strftime
(
'
%
Y
%
m
%
d
T
%
H
%
M
%
S'
)
]
if
part_num
is
not
None
:
elements
.
append
(
str
(
part_num
))
...
...
setup.py
浏览文件 @
3bd7a14b
...
...
@@ -25,7 +25,7 @@ requires = [
setuptools
.
setup
(
name
=
'ils-common-video'
,
version
=
'2.
0
.0'
,
version
=
'2.
1
.0'
,
description
=
'ISC motion detection playback video stream recording service.'
,
long_description
=
long_description
,
long_description_content_type
=
'text/markdown'
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论