Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
075a615a
Commit
075a615a
authored
Feb 01, 2020
by
xiongziliang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'research' of
https://gitee.com/liuziloong/FreeNVR
parents
92f69c39
795860a0
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
126 行增加
和
5 行删除
+126
-5
server/FFmpegSource.cpp
+5
-0
server/Process.cpp
+1
-1
server/WebApi.cpp
+114
-0
src/Extension/SPSParser.c
+1
-1
src/Record/MP4Recorder.cpp
+5
-3
没有找到文件。
server/FFmpegSource.cpp
查看文件 @
075a615a
...
...
@@ -34,6 +34,7 @@ namespace FFmpeg {
#define FFmpeg_FIELD "ffmpeg."
const
string
kBin
=
FFmpeg_FIELD
"bin"
;
const
string
kCmd
=
FFmpeg_FIELD
"cmd"
;
const
string
kSnap
=
FFmpeg_FIELD
"snap"
;
const
string
kLog
=
FFmpeg_FIELD
"log"
;
onceToken
token
([]()
{
...
...
@@ -41,9 +42,12 @@ onceToken token([]() {
string
ffmpeg_bin
=
System
::
execute
(
"where ffmpeg"
);
//windows下先关闭FFmpeg日志(目前不支持日志重定向)
mINI
::
Instance
()[
kCmd
]
=
"%s -re -i
\"
%s
\"
-loglevel quiet -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s "
;
//利用ffmpeg进行抓拍
mINI
::
Instance
()[
kSnap
]
=
"%s -i
\"
%s
\"
-loglevel quiet -y -f mjpeg -t 0.001 -s 720*576 %s "
;
#else
string
ffmpeg_bin
=
System
::
execute
(
"which ffmpeg"
);
mINI
::
Instance
()[
kCmd
]
=
"%s -re -i
\"
%s
\"
-c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s "
;
mINI
::
Instance
()[
kSnap
]
=
"%s -i
\"
%s
\"
-y -f mjpeg -t 0.001 -s 720*576 %s "
;
#endif
//默认ffmpeg命令路径为环境变量中路径
mINI
::
Instance
()[
kBin
]
=
ffmpeg_bin
.
empty
()
?
"ffmpeg"
:
ffmpeg_bin
;
...
...
@@ -64,6 +68,7 @@ FFmpegSource::~FFmpegSource() {
void
FFmpegSource
::
play
(
const
string
&
src_url
,
const
string
&
dst_url
,
int
timeout_ms
,
const
onPlay
&
cb
)
{
GET_CONFIG
(
string
,
ffmpeg_bin
,
FFmpeg
::
kBin
);
GET_CONFIG
(
string
,
ffmpeg_cmd
,
FFmpeg
::
kCmd
);
GET_CONFIG
(
string
,
ffmpeg_snap
,
FFmpeg
::
kSnap
);
GET_CONFIG
(
string
,
ffmpeg_log
,
FFmpeg
::
kLog
);
_src_url
=
src_url
;
...
...
server/Process.cpp
查看文件 @
075a615a
...
...
@@ -53,7 +53,7 @@ void Process::run(const string &cmd, const string &log_file_tmp) {
ZeroMemory
(
&
si
,
sizeof
(
si
));
//结构体初始化;
ZeroMemory
(
&
pi
,
sizeof
(
pi
));
LPTSTR
lpDir
=
const_cast
<
char
*>
(
cmd
.
data
());
LPTSTR
lpDir
=
const_cast
<
char
*>
(
cmd
.
data
());
if
(
CreateProcess
(
NULL
,
lpDir
,
NULL
,
NULL
,
FALSE
,
0
,
NULL
,
NULL
,
&
si
,
&
pi
)){
//下面两行关闭句柄,解除本进程和新进程的关系,不然有可能 不小心调用TerminateProcess函数关掉子进程
...
...
server/WebApi.cpp
查看文件 @
075a615a
...
...
@@ -71,6 +71,7 @@ static onceToken token([]() {
});
}
//namespace API
class
ApiRetException
:
public
std
::
runtime_error
{
public
:
ApiRetException
(
const
char
*
str
=
"success"
,
int
code
=
API
::
Success
)
:
runtime_error
(
str
){
...
...
@@ -773,6 +774,119 @@ void installWebApi() {
val
[
"status"
]
=
(
int
)
status
;
});
//获取录像列表(按月),返回天
//http://127.0.0.1/index/api/getMp4RecordMonthly?app=live&stream=onvif&period=2020-01
api_regist1
(
"/index/api/getMp4RecordMonthly"
,
[](
API_ARGS1
){
CHECK_SECRET
();
CHECK_ARGS
(
"app"
,
"stream"
,
"period"
);
GET_CONFIG
(
string
,
recordAppName
,
Record
::
kAppName
);
GET_CONFIG
(
string
,
recordPath
,
Record
::
kFilePath
);
GET_CONFIG
(
bool
,
enableVhost
,
General
::
kEnableVhost
);
auto
_vhost
=
allArgs
[
"vhost"
];
auto
_app
=
allArgs
[
"app"
];
auto
_stream
=
allArgs
[
"stream"
];
auto
_period
=
allArgs
[
"period"
];
//TODO:判断日期格式
//Vhost为空的话,存储路径不一样
if
(
_vhost
.
empty
())
{
_vhost
=
DEFAULT_VHOST
;
}
string
strMp4RecordPath
=
""
;
if
(
enableVhost
)
{
strMp4RecordPath
=
recordPath
+
"/"
+
_vhost
+
"/"
+
recordAppName
+
"/"
+
_app
+
"/"
+
_stream
+
"/"
+
_period
;
}
else
{
strMp4RecordPath
=
recordPath
+
"/"
+
recordAppName
+
"/"
+
_app
+
"/"
+
_stream
+
"/"
+
_period
;
}
//录像相对路径转绝对路径, 不然vs调试需要设置
strMp4RecordPath
=
File
::
absolutePath
(
strMp4RecordPath
,
""
);
string
strMp4Path
=
""
;
File
::
scanDir
(
strMp4RecordPath
,
[
&
strMp4Path
](
const
string
&
path
,
bool
isDir
)
{
if
(
isDir
)
{
//DebugL << "dir:" << path.data();
int
iPost
=
path
.
rfind
(
'/'
);
if
(
iPost
!=
string
::
npos
)
{
string
strPath
=
path
.
substr
(
iPost
+
1
);
strMp4Path
+=
strPath
+
","
;
}
}
return
true
;
},
false
);
//去掉strMp4Path最后一个 ‘,’
strMp4Path
=
strMp4Path
.
substr
(
0
,
strMp4Path
.
length
()
-
1
);
Json
::
Value
nVal
;
nVal
[
"vhost"
]
=
_vhost
.
data
();
nVal
[
"app"
]
=
_app
.
data
();
nVal
[
"stream"
]
=
_stream
.
data
();
nVal
[
"app"
]
=
_app
.
data
();
nVal
[
"path"
]
=
strMp4Path
;
val
[
"data"
]
=
nVal
;
});
//获取录像列表(按天)
//http://127.0.0.1/index/api/getMp4RecordDaily?app=live&stream=onvif&period=2020-01-17
api_regist1
(
"/index/api/getMp4RecordDaily"
,[](
API_ARGS1
)
{
CHECK_SECRET
();
CHECK_ARGS
(
"app"
,
"stream"
,
"period"
);
GET_CONFIG
(
string
,
recordAppName
,
Record
::
kAppName
);
GET_CONFIG
(
string
,
recordPath
,
Record
::
kFilePath
);
GET_CONFIG
(
bool
,
enableVhost
,
General
::
kEnableVhost
);
auto
_vhost
=
allArgs
[
"vhost"
];
auto
_app
=
allArgs
[
"app"
];
auto
_stream
=
allArgs
[
"stream"
];
auto
_period
=
allArgs
[
"period"
];
//TODO:判断日期格式
//Vhost为空的话,存储路径不一样
if
(
_vhost
.
empty
())
{
_vhost
=
DEFAULT_VHOST
;
}
string
strMp4RecordPath
=
""
;
//取录上一级目录,默认前7位位上级目录
string
strParentPeriod
=
string
(
_period
).
substr
(
0
,
7
);
if
(
enableVhost
)
{
strMp4RecordPath
=
recordPath
+
"/"
+
_vhost
+
"/"
+
recordAppName
+
"/"
+
_app
+
"/"
+
_stream
+
"/"
+
strParentPeriod
+
"/"
+
_period
;
}
else
{
strMp4RecordPath
=
recordPath
+
"/"
+
recordAppName
+
"/"
+
_app
+
"/"
+
_stream
+
"/"
+
strParentPeriod
+
"/"
+
_period
;
}
//录像相对路径转绝对路径, 不然vs调试需要设置
strMp4RecordPath
=
File
::
absolutePath
(
strMp4RecordPath
,
""
);
Json
::
Value
nVal
;
DebugL
<<
recordPath
;
File
::
scanDir
(
strMp4RecordPath
,
[
&
](
const
string
&
path
,
bool
isDir
)
{
if
(
!
isDir
)
{
//去掉绝对路径,从record开始返回
int
iPos
=
path
.
find
(
recordAppName
);
string
strPath
=
path
.
substr
(
iPos
);
nVal
[
"path"
].
append
(
strPath
);
}
return
true
;
},
false
);
nVal
[
"vhost"
]
=
_vhost
.
data
();
nVal
[
"app"
]
=
_app
.
data
();
nVal
[
"stream"
]
=
_stream
.
data
();
nVal
[
"app"
]
=
_app
.
data
();
val
[
"data"
]
=
nVal
;
});
////////////以下是注册的Hook API////////////
api_regist1
(
"/index/hook/on_publish"
,[](
API_ARGS1
){
//开始推流事件
...
...
src/Extension/SPSParser.c
查看文件 @
075a615a
...
...
@@ -1330,7 +1330,7 @@ int hevcDecodeShortTermRps(T_GetBitContext *pvBuf,
int
iDeltaRps
;
unsigned
int
uiAbsDeltaRps
;
uint8_t
u8UseDeltaFlag
=
0
;
uint8_t
u8DeltaRpsSign
;
uint8_t
u8DeltaRpsSign
=
0
;
if
(
is_slice_header
)
{
unsigned
int
uiDeltaIdx
=
parseUe
(
pvBuf
)
+
1
;
...
...
src/Record/MP4Recorder.cpp
查看文件 @
075a615a
...
...
@@ -52,10 +52,11 @@ MP4Recorder::~MP4Recorder() {
void
MP4Recorder
::
createFile
()
{
closeFile
();
auto
strDate
=
getTimeStr
(
"%Y-%m-%d"
);
auto
strDate
=
getTimeStr
(
"%Y-%m"
);
auto
strDay
=
getTimeStr
(
"%Y-%m-%d"
);
auto
strTime
=
getTimeStr
(
"%H-%M-%S"
);
auto
strFileTmp
=
_strPath
+
strDate
+
"/."
+
strTime
+
".mp4"
;
auto
strFile
=
_strPath
+
strDate
+
"/"
+
strTime
+
".mp4"
;
auto
strFileTmp
=
_strPath
+
strDate
+
"/
"
+
strDay
+
"/
."
+
strTime
+
".mp4"
;
auto
strFile
=
_strPath
+
strDate
+
"/"
+
str
Day
+
"/"
+
str
Time
+
".mp4"
;
/////record 业务逻辑//////
_info
.
ui64StartedTime
=
::
time
(
NULL
);
...
...
@@ -66,6 +67,7 @@ void MP4Recorder::createFile() {
+
_info
.
strAppName
+
"/"
+
_info
.
strStreamId
+
"/"
+
strDate
+
"/"
+
strDay
+
"/"
+
strTime
+
".mp4"
;
try
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论