Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
69046a88
提交
69046a88
authored
9月 24, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
big refacting of communitation architect
上级
8e055408
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
37 行增加
和
6 行删除
+37
-6
evslicer.cpp
opencv-motion-detect/evslicer.cpp
+35
-5
fs_test.cpp
opencv-motion-detect/fs_test.cpp
+2
-1
没有找到文件。
opencv-motion-detect/evslicer.cpp
浏览文件 @
69046a88
...
@@ -44,8 +44,8 @@ private:
...
@@ -44,8 +44,8 @@ private:
void
*
pSubCtx
=
nullptr
,
*
pDealerCtx
=
nullptr
;
// for packets relay
void
*
pSubCtx
=
nullptr
,
*
pDealerCtx
=
nullptr
;
// for packets relay
void
*
pSub
=
nullptr
,
*
pDealer
=
nullptr
,
*
pDaemonCtx
=
nullptr
,
*
pDaemon
=
nullptr
;
void
*
pSub
=
nullptr
,
*
pDealer
=
nullptr
,
*
pDaemonCtx
=
nullptr
,
*
pDaemon
=
nullptr
;
string
urlOut
,
urlPub
,
urlRouter
,
devSn
,
mgrSn
,
selfId
,
pullerGid
;
string
urlOut
,
urlPub
,
urlRouter
,
devSn
,
mgrSn
,
selfId
,
pullerGid
;
int
iid
,
days
,
minutes
,
numSlices
,
segHead
=
0
,
segTail
=
0
;
int
iid
,
days
,
minutes
,
numSlices
,
segHead
=
0
;
bool
enablePush
=
false
;
bool
enablePush
=
false
,
bSegFull
=
false
;
AVFormatContext
*
pAVFormatRemux
=
nullptr
;
AVFormatContext
*
pAVFormatRemux
=
nullptr
;
AVFormatContext
*
pAVFormatInput
=
nullptr
;
AVFormatContext
*
pAVFormatInput
=
nullptr
;
AVDictionary
*
pOptsRemux
=
nullptr
;
AVDictionary
*
pOptsRemux
=
nullptr
;
...
@@ -57,8 +57,11 @@ private:
...
@@ -57,8 +57,11 @@ private:
json
slices
;
json
slices
;
bool
gotFormat
=
false
;
bool
gotFormat
=
false
;
vector
<
long
>
vTsOld
;
vector
<
long
>
vTsOld
;
mutex
mutTsOld
;
vector
<
long
>
vTsActive
;
vector
<
long
>
vTsActive
;
mutex
mutTsActive
;
map
<
long
,
string
>
mapTs2BaseName
;
map
<
long
,
string
>
mapTs2BaseName
;
mutex
mutTs2BaseName
;
int
handleMsg
(
vector
<
vector
<
uint8_t
>
>
v
)
int
handleMsg
(
vector
<
vector
<
uint8_t
>
>
v
)
{
{
...
@@ -356,7 +359,7 @@ protected:
...
@@ -356,7 +359,7 @@ protected:
spdlog
::
error
(
"evslicer {} could not open output file {}"
,
selfId
,
name
);
spdlog
::
error
(
"evslicer {} could not open output file {}"
,
selfId
,
name
);
}
}
}
}
av_dict_set
(
&
pOptsRemux
,
"segment_start_number"
,
to_string
(
seg
Tail
).
data
(),
0
);
av_dict_set
(
&
pOptsRemux
,
"segment_start_number"
,
to_string
(
seg
Head
).
data
(),
0
);
ret
=
avformat_write_header
(
pAVFormatRemux
,
&
pOptsRemux
);
ret
=
avformat_write_header
(
pAVFormatRemux
,
&
pOptsRemux
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
spdlog
::
error
(
"evslicer {} error occurred when opening output file"
,
selfId
);
spdlog
::
error
(
"evslicer {} error occurred when opening output file"
,
selfId
);
...
@@ -545,7 +548,35 @@ protected:
...
@@ -545,7 +548,35 @@ protected:
spdlog
::
info
(
"evslicer {} filemon file: {}, ts: {}"
,
self
->
selfId
,
i
.
get_path
().
c_str
(),
i
.
get_time
());
spdlog
::
info
(
"evslicer {} filemon file: {}, ts: {}"
,
self
->
selfId
,
i
.
get_path
().
c_str
(),
i
.
get_time
());
if
(
lastFile
==
i
.
get_path
())
{
if
(
lastFile
==
i
.
get_path
())
{
// skip
// skip
}
else
if
(
!
lastFile
.
empty
()){
// insert into ts active
auto
lockg
=
lock_guard
(
self
->
mutTsActive
);
if
(
self
->
segHead
>=
self
->
numSlices
)
{
//wrap it;
self
->
segHead
=
0
;
self
->
bSegFull
=
true
;
}
if
(
self
->
bSegFull
)
{
// TODO: backup orignal self->vTsActive[self->segHead]
}
try
{
auto
ftime
=
fs
::
last_write_time
(
i
.
get_path
());
auto
baseName
=
getBaseName
(
i
.
get_path
());
auto
ts
=
decltype
(
ftime
)
::
clock
::
to_time_t
(
ftime
);
auto
oldTs
=
self
->
vTsActive
[
self
->
segHead
];
self
->
vTsActive
[
self
->
segHead
]
=
ts
;
self
->
mapTs2BaseName
[
ts
]
=
baseName
;
// erase old ts to save memory
self
->
mapTs2BaseName
.
erase
(
oldTs
);
self
->
segHead
++
;
spdlog
::
info
(
"evslicer {} fileMonHandler video seg done :{}/{}.mp4, ts:{}"
,
self
->
selfId
,
self
->
urlOut
,
baseName
,
ts
);
}
catch
(
exception
&
e
)
{
spdlog
::
error
(
"evslicer {} fileMonHandler exception: {}"
,
self
->
selfId
,
e
.
what
());
}
}
else
{
}
else
{
//nop
}
}
}
}
}
}
...
@@ -612,8 +643,7 @@ public:
...
@@ -612,8 +643,7 @@ public:
thSliceMgr
=
thread
([
this
]()
{
thSliceMgr
=
thread
([
this
]()
{
// get old and active slices
// get old and active slices
this
->
vTsActive
=
this
->
LoadVideoFiles
(
this
->
urlOut
,
this
->
days
,
this
->
numSlices
,
this
->
mapTs2BaseName
,
this
->
vTsOld
);
this
->
vTsActive
=
this
->
LoadVideoFiles
(
this
->
urlOut
,
this
->
days
,
this
->
numSlices
,
this
->
mapTs2BaseName
,
this
->
vTsOld
);
this
->
segHead
=
0
;
this
->
segHead
=
this
->
vTsActive
.
size
();
this
->
segTail
=
vTsActive
.
size
();
monitor
*
m
=
nullptr
;
monitor
*
m
=
nullptr
;
CreateDirMon
(
&
m
,
this
->
urlOut
,
".mp4"
,
vector
<
string
>
(),
EvSlicer
::
fileMonHandler
,
(
void
*
)
this
);
CreateDirMon
(
&
m
,
this
->
urlOut
,
".mp4"
,
vector
<
string
>
(),
EvSlicer
::
fileMonHandler
,
(
void
*
)
this
);
...
...
opencv-motion-detect/fs_test.cpp
浏览文件 @
69046a88
...
@@ -98,7 +98,7 @@ vector<long> LoadVideoFiles(string path, int days, int maxSlices, map<long, stri
...
@@ -98,7 +98,7 @@ vector<long> LoadVideoFiles(string path, int days, int maxSlices, map<long, stri
list
<
long
>
olds
;
list
<
long
>
olds
;
int
delta
=
maxSlices
-
tsRing
.
size
();
int
delta
=
maxSlices
-
tsRing
.
size
();
int
skip
=
delta
<
0
?
(
-
delta
)
:
0
;
int
skip
=
delta
<
0
?
(
-
delta
)
:
0
;
spdlog
::
info
(
"LoasdVideoFiles max: {}, current: {}, skip: {}"
,
maxSlices
,
tsRing
.
size
(),
skip
);
spdlog
::
info
(
"LoasdVideoFiles max: {}, current: {}, skip: {}"
,
maxSlices
,
tsRing
.
size
(),
skip
);
int
idx
=
0
;
int
idx
=
0
;
list
<
long
>::
iterator
pos
=
tsRing
.
begin
();
list
<
long
>::
iterator
pos
=
tsRing
.
begin
();
for
(
auto
&
i
:
tsRing
)
{
for
(
auto
&
i
:
tsRing
)
{
...
@@ -109,6 +109,7 @@ vector<long> LoadVideoFiles(string path, int days, int maxSlices, map<long, stri
...
@@ -109,6 +109,7 @@ vector<long> LoadVideoFiles(string path, int days, int maxSlices, map<long, stri
}
}
v
.
push_back
(
i
);
v
.
push_back
(
i
);
}
}
// merge
// merge
if
(
skip
>
0
)
{
if
(
skip
>
0
)
{
tsNeedProc
.
insert
(
std
::
upper_bound
(
tsNeedProc
.
begin
(),
tsNeedProc
.
end
(),
tsRing
.
front
()),
tsRing
.
begin
(),
pos
);
tsNeedProc
.
insert
(
std
::
upper_bound
(
tsNeedProc
.
begin
(),
tsNeedProc
.
end
(),
tsRing
.
front
()),
tsRing
.
begin
(),
pos
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论