Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
I
ils-common-video
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
提交
议题看板
打开侧边栏
OpsTeam
ils-common-video
Commits
988ae036
提交
988ae036
authored
5月 06, 2021
作者:
zw.wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 修复mysql变更
上级
15df0e6b
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
19 行增加
和
11 行删除
+19
-11
mysql.py
hikvision_isc_client/db/mysql.py
+6
-7
recorder.py
hikvision_isc_client/recorder.py
+7
-3
record_utils.py
hikvision_isc_client/utils/record_utils.py
+6
-1
没有找到文件。
hikvision_isc_client/db/mysql.py
浏览文件 @
988ae036
...
@@ -101,19 +101,19 @@ def get_camera_info(cursor, conn):
...
@@ -101,19 +101,19 @@ def get_camera_info(cursor, conn):
@query
()
@query
()
def
insert_video_info
(
cursor
,
conn
,
db_table
,
device_code
,
file_name
,
start_time
,
end_time
,
def
insert_video_info
(
cursor
,
conn
,
db_table
,
device_code
,
file_name
,
start_time
,
end_time
,
recovered_time
,
date
,
video_url
,
video_resolution
,
status
=
0
):
recovered_time
,
video_url
,
video_resolution
,
status
=
0
):
sql
=
'''
sql
=
'''
insert {} (
insert {} (
device_code, file_name, start_date, end_date,
device_code, file_name, start_date, end_date,
recovered_time,
date,
recovered_time,
video_url, video_resolution,
video_url, video_resolution,
biz_type, service_type,
biz_type, service_type,
expired_time, status, update_time)
expired_time, status, update_time
, create_time
)
value (
%(device_code)
s,
%(file_name)
s,
%(start_
date)
s,
%(end_dat
e)
s,
value (
%(device_code)
s,
%(file_name)
s,
%(start_
time)
s,
%(end_tim
e)
s,
%(recovered_time)
s,
%(date)
s,
%(recovered_time)
s,
%(video_url)
s,
%(video_resolution)
s,
%(video_url)
s,
%(video_resolution)
s,
1, 1,
1, 1,
date_add(now(),interval 31 day),
%(status)
s, now()
date_add(now(),interval 31 day),
%(status)
s, now()
, now()
)
)
'''
.
format
(
db_table
)
'''
.
format
(
db_table
)
cursor
.
execute
(
sql
,
{
cursor
.
execute
(
sql
,
{
...
@@ -124,7 +124,6 @@ def insert_video_info(cursor, conn, db_table, device_code, file_name, start_time
...
@@ -124,7 +124,6 @@ def insert_video_info(cursor, conn, db_table, device_code, file_name, start_time
'video_url'
:
video_url
,
'video_url'
:
video_url
,
'video_resolution'
:
video_resolution
,
'video_resolution'
:
video_resolution
,
'recovered_time'
:
recovered_time
,
'recovered_time'
:
recovered_time
,
'date'
:
date
,
'status'
:
status
'status'
:
status
})
})
video_id
=
cursor
.
lastrowid
video_id
=
cursor
.
lastrowid
...
...
hikvision_isc_client/recorder.py
浏览文件 @
988ae036
import
json
import
json
import
os
import
os
import
shutil
import
shutil
import
time
import
threading
import
threading
import
functools
import
functools
import
pytz
import
pytz
...
@@ -89,14 +90,18 @@ class StreamRecorder:
...
@@ -89,14 +90,18 @@ class StreamRecorder:
self
.
connection
.
close
()
self
.
connection
.
close
()
def
process_message
(
self
,
body
):
def
process_message
(
self
,
body
):
t1
=
time
.
time
()
record_result
=
self
.
recorder
(
record_result
=
self
.
recorder
(
body
[
'camera_index'
],
body
[
'camera_index'
],
datetime
.
strptime
(
body
[
'start_time'
],
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S'
)
.
astimezone
(
tz
),
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
),
datetime
.
strptime
(
body
[
'end_time'
],
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S'
)
.
astimezone
(
tz
),
body
[
'camera_code'
]
body
[
'camera_code'
]
)
)
t2
=
time
.
time
()
video_info
,
error_log
=
get_video_duration
(
record_result
[
'file_name'
])
video_info
,
error_log
=
get_video_duration
(
record_result
[
'file_name'
])
log
.
info
(
'record Time:
%
s, duration:
%
s, size:
%
s'
,
round
(
t2
-
t1
,
2
),
video_info
[
'duration'
],
video_info
[
'size'
])
url
=
''
url
=
''
file_name
=
record_result
[
'file_name'
]
.
split
(
'/'
)[
-
1
]
file_name
=
record_result
[
'file_name'
]
.
split
(
'/'
)[
-
1
]
if
record_result
[
'file_name'
]
and
os
.
path
.
isfile
(
record_result
[
'file_name'
]):
if
record_result
[
'file_name'
]
and
os
.
path
.
isfile
(
record_result
[
'file_name'
]):
...
@@ -104,10 +109,9 @@ class StreamRecorder:
...
@@ -104,10 +109,9 @@ class StreamRecorder:
record_result
[
'file_name'
])
record_result
[
'file_name'
])
os
.
remove
(
record_result
[
'file_name'
])
os
.
remove
(
record_result
[
'file_name'
])
video_id
=
insert_video_info
(
body
[
'db_table'
],
body
[
'camera_code'
],
file_name
,
body
[
'start_time'
],
video_id
=
insert_video_info
(
body
[
'db_table'
],
body
[
'camera_code'
],
file_name
,
body
[
'end_time'
],
body
[
'
start_time'
],
body
[
'
end_time'
],
recovered_time
=
record_result
[
'recovered_time'
]
.
astimezone
(
pytz
.
utc
),
recovered_time
=
record_result
[
'recovered_time'
]
.
astimezone
(
pytz
.
utc
),
date
=
body
[
'start_time'
]
.
split
(
'T'
)[
0
]
.
replace
(
'-'
,
''
),
video_url
=
url
,
video_resolution
=
video_info
[
'resolution'
],
video_url
=
url
,
video_resolution
=
video_info
[
'resolution'
],
status
=
1
if
record_result
[
'is_completed'
]
else
2
)
status
=
1
if
record_result
[
'is_completed'
]
else
2
)
log
.
info
(
'video_info:
%
s, url:
%
s, video_id:
%
s.
%
s'
,
video_info
,
url
,
body
[
'db_table'
],
video_id
)
log
.
info
(
'video_info:
%
s, url:
%
s, video_id:
%
s.
%
s'
,
video_info
,
url
,
body
[
'db_table'
],
video_id
)
...
...
hikvision_isc_client/utils/record_utils.py
浏览文件 @
988ae036
import
re
import
re
import
os
import
subprocess
import
subprocess
from
intelab_python_sdk.logger
import
log
from
intelab_python_sdk.logger
import
log
...
@@ -59,6 +60,7 @@ def get_video_duration(file_name):
...
@@ -59,6 +60,7 @@ def get_video_duration(file_name):
bitrate
=
[
'0'
]
bitrate
=
[
'0'
]
resolution
=
[
'0x0'
]
resolution
=
[
'0x0'
]
media_type
=
'VideoHandler'
media_type
=
'VideoHandler'
size
=
0
log_buffer
=
subprocess
.
getoutput
(
'ffmpeg -i {}'
.
format
(
file_name
))
log_buffer
=
subprocess
.
getoutput
(
'ffmpeg -i {}'
.
format
(
file_name
))
if
'moov atom not found'
in
log_buffer
:
if
'moov atom not found'
in
log_buffer
:
...
@@ -70,13 +72,16 @@ def get_video_duration(file_name):
...
@@ -70,13 +72,16 @@ def get_video_duration(file_name):
resolution
=
re
.
findall
(
r'(\d{3,4}x\d{3,4})'
,
log_buffer
)
or
resolution
resolution
=
re
.
findall
(
r'(\d{3,4}x\d{3,4})'
,
log_buffer
)
or
resolution
if
'SoundHandler'
in
log_buffer
:
if
'SoundHandler'
in
log_buffer
:
media_type
+=
'+SoundHandler'
media_type
+=
'+SoundHandler'
if
os
.
path
.
isfile
(
file_name
):
size
=
os
.
path
.
getsize
(
file_name
)
/
1024.0
video_info
=
{
video_info
=
{
'duration'
:
duration
[
0
],
'duration'
:
duration
[
0
],
'bitrate'
:
bitrate
[
0
],
'bitrate'
:
bitrate
[
0
],
'resolution'
:
resolution
[
0
],
'resolution'
:
resolution
[
0
],
'media_type'
:
media_type
,
'media_type'
:
media_type
,
'file_name'
:
file_name
'file_name'
:
file_name
,
'size'
:
size
}
}
return
video_info
,
error_log
return
video_info
,
error_log
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论