Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
3caa6fab
提交
3caa6fab
authored
4月 13, 2020
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new upload script with /mnt/sd card as backup
上级
7b32b236
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
72 行增加
和
1 行删除
+72
-1
test.html
opencv-motion-detect/deployment/test.html
+2
-1
upload_video.py
opencv-motion-detect/upload_video.py
+0
-0
upload_video_origin.py
opencv-motion-detect/upload_video_origin.py
+70
-0
没有找到文件。
opencv-motion-detect/deployment/test.html
浏览文件 @
3caa6fab
...
@@ -6,5 +6,5 @@
...
@@ -6,5 +6,5 @@
</script>
</script>
<video
id=
"example_video_1"
class=
"video-js vjs-default-skin"
controls
preload=
"true"
width=
"640"
height=
"320"
<video
id=
"example_video_1"
class=
"video-js vjs-default-skin"
controls
preload=
"true"
width=
"640"
height=
"320"
data-setup=
'{"autoplay": "true"}'
>
data-setup=
'{"autoplay": "true"}'
>
<source
src=
"
rtmp://qz.videostreaming.ilabservice.cloud:1935/hls/D72158932"
type=
'flv
'
/>
<source
src=
"
./output.mp4"
type=
'mp4
'
/>
</video>
</video>
\ No newline at end of file
opencv-motion-detect/upload_video.py
浏览文件 @
3caa6fab
差异被折叠。
点击展开。
opencv-motion-detect/upload_video_origin.py
0 → 100644
浏览文件 @
3caa6fab
import
requests
,
glob
,
os
,
json
,
socket
,
datetime
,
time
,
sys
import
pdb
import
traceback
FILE_PATH
=
os
.
getenv
(
'FILE_PATH'
,
'/var/data/evsuits/failed_events/'
)
VIDEO_PATH
=
os
.
getenv
(
'VIDEO_PATH'
,
'/root/work/opencv-pocs/opencv-motion-detect/'
)
API_ADDR
=
os
.
getenv
(
'API_ADDR'
,
'http://evcloudsvc.ilabservice.cloud:10009/upload/evtvideos/'
)
#{"fileNames":["slices/237808840_3/20200304_124406.mp4","slices/237808840_3/20200304_124437.mp4"],"params":{"cameraId":"237808840","endTime":"1583297091","headOffset":"0","startTime":"1583297066","tailOffset":"0","type":"event"}}
def
upload_file
(
file
):
success
=
False
fileNames
=
[]
try
:
with
open
(
file
)
as
jf
:
data
=
json
.
load
(
jf
)
print
(
"data: "
,
data
,
file
)
fileNames
=
[
"{}{}"
.
format
(
VIDEO_PATH
,
x
)
for
x
in
data
[
"fileNames"
]]
blob
=
[(
'files'
,
open
(
f
,
'rb'
))
for
f
in
fileNames
]
url
=
API_ADDR
+
data
[
"params"
][
"cameraId"
]
+
'?'
+
'&'
.
join
([
"{}={}"
.
format
(
k
,
v
)
for
k
,
v
in
data
[
"params"
]
.
items
()])
r
=
requests
.
post
(
url
,
files
=
blob
,
timeout
=
60
*
10
)
print
(
file
,
fileNames
,
r
.
status_code
,
r
.
text
)
if
(
r
.
status_code
==
200
and
(
'code'
in
r
.
json
())
and
r
.
json
()[
'code'
]
==
0
):
success
=
True
if
success
:
os
.
remove
(
file
)
# for f in fileNames:
# try:
# os.remove(f)
# except:
# pass
except
requests
.
exceptions
.
ConnectionError
as
e
:
print
(
"Error Connecting:"
,
e
)
except
requests
.
exceptions
.
Timeout
as
e
:
print
(
"Timeout Error:"
,
e
)
except
requests
.
exceptions
.
RequestException
as
e
:
print
(
"Request Exception"
,
e
)
except
IOError
as
e
:
success
=
True
# file io error
os
.
remove
(
file
)
print
(
"IOError Exception:"
,
e
)
except
Exception
as
e
:
print
(
"General Exception:"
,
e
)
return
success
def
list_files
(
dir
):
out
=
glob
.
glob
(
"{}/*.json"
.
format
(
dir
))
out
.
sort
(
key
=
os
.
path
.
getmtime
)
# prevent memory overflow
if
len
(
out
)
>
5
:
out
=
out
[:
5
]
return
out
if
__name__
==
"__main__"
:
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
bind
((
'localhost'
,
45431
))
files
=
list_files
(
FILE_PATH
)
for
f
in
files
:
now
=
time
.
mktime
(
datetime
.
datetime
.
now
()
.
timetuple
())
mts
=
os
.
path
.
getmtime
(
f
)
# defer those files may still in recording
if
now
-
mts
<
35
:
continue
res
=
upload_file
(
f
)
if
res
:
continue
else
:
# TODO: report
break
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论