Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-08-03 13:06:37 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5a95d594e7d422b38cb3985e68a765c50cf3f2d9
5a95d594
1 parent
d5ba529d
fix #145, refine ffmpeg log, check abitrate for libaacplus. 0.9.186.
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
44 行增加
和
22 行删除
README.md
trunk/src/app/srs_app_ffmpeg.cpp
trunk/src/core/srs_core.hpp
README.md
查看文件 @
5a95d59
...
...
@@ -207,7 +207,8 @@ Supported operating systems and hardware:
*
2013-10-17, Created.
<br/>
## History
*
v1.0, 2014-08-02, fix
[
#143
](
https://github.com/winlinvip/simple-rtmp-server/issues/143
)
, fix retrieve sys stat bug for all linux. 0.9.185.
*
v1.0, 2014-08-03, fix
[
#145
](
https://github.com/winlinvip/simple-rtmp-server/issues/145
)
, refine ffmpeg log, check abitrate for libaacplus. 0.9.186.
*
v1.0, 2014-08-03, fix
[
#143
](
https://github.com/winlinvip/simple-rtmp-server/issues/143
)
, fix retrieve sys stat bug for all linux. 0.9.185.
*
v1.0, 2014-08-02, fix
[
#138
](
https://github.com/winlinvip/simple-rtmp-server/issues/138
)
, fix http hooks bug, regression bug. 0.9.184.
*
v1.0, 2014-08-02, fix
[
#142
](
https://github.com/winlinvip/simple-rtmp-server/issues/142
)
, fix tcp stat slow bug, use /proc/net/sockstat instead, refer to 'ss -s'. 0.9.183.
*
v1.0, 2014-07-31, fix
[
#141
](
https://github.com/winlinvip/simple-rtmp-server/issues/141
)
, support tun0(vpn network device) ip retrieve. 0.9.179.
...
...
trunk/src/app/srs_app_ffmpeg.cpp
查看文件 @
5a95d59
...
...
@@ -41,14 +41,15 @@ using namespace std;
#ifdef SRS_AUTO_FFMPEG
#define SRS_RTMP_ENCODER_COPY "copy"
#define SRS_RTMP_ENCODER_NO_VIDEO "vn"
#define SRS_RTMP_ENCODER_NO_AUDIO "an"
#define SRS_RTMP_ENCODER_COPY "copy"
#define SRS_RTMP_ENCODER_NO_VIDEO "vn"
#define SRS_RTMP_ENCODER_NO_AUDIO "an"
// only support libx264 encoder.
#define SRS_RTMP_ENCODER_VCODEC "libx264"
#define SRS_RTMP_ENCODER_VCODEC
"libx264"
// any aac encoder is ok which contains the aac,
// for example, libaacplus, aac, fdkaac
#define SRS_RTMP_ENCODER_ACODEC "aac"
#define SRS_RTMP_ENCODER_ACODEC "aac"
#define SRS_RTMP_ENCODER_LIBAACPLUS "libaacplus"
SrsFFMPEG
::
SrsFFMPEG
(
std
::
string
ffmpeg_bin
)
{
...
...
@@ -173,6 +174,15 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine)
}
}
// @see, https://github.com/winlinvip/simple-rtmp-server/issues/145
if
(
acodec
==
SRS_RTMP_ENCODER_LIBAACPLUS
)
{
if
(
abitrate
<
16
||
abitrate
>
72
)
{
ret
=
ERROR_ENCODER_ABITRATE
;
srs_error
(
"invalid abitrate for aac: %d, must in [16, 72], ret=%d"
,
abitrate
,
ret
);
return
ret
;
}
}
if
(
acodec
!=
SRS_RTMP_ENCODER_COPY
&&
acodec
!=
SRS_RTMP_ENCODER_NO_AUDIO
)
{
if
(
acodec
.
find
(
SRS_RTMP_ENCODER_ACODEC
)
==
std
::
string
::
npos
)
{
ret
=
ERROR_ENCODER_ACODEC
;
...
...
@@ -182,20 +192,17 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine)
}
if
(
abitrate
<=
0
)
{
ret
=
ERROR_ENCODER_ABITRATE
;
srs_error
(
"invalid abitrate: %d, ret=%d"
,
abitrate
,
ret
);
srs_error
(
"invalid abitrate: %d, ret=%d"
,
abitrate
,
ret
);
return
ret
;
}
if
(
asample_rate
<=
0
)
{
ret
=
ERROR_ENCODER_ASAMPLE_RATE
;
srs_error
(
"invalid sample rate: %d, ret=%d"
,
asample_rate
,
ret
);
srs_error
(
"invalid sample rate: %d, ret=%d"
,
asample_rate
,
ret
);
return
ret
;
}
if
(
achannels
!=
1
&&
achannels
!=
2
)
{
ret
=
ERROR_ENCODER_ACHANNELS
;
srs_error
(
"invalid achannels, must be 1 or 2, actual %d, ret=%d"
,
achannels
,
ret
);
srs_error
(
"invalid achannels, must be 1 or 2, actual %d, ret=%d"
,
achannels
,
ret
);
return
ret
;
}
}
...
...
@@ -359,21 +366,21 @@ int SrsFFMPEG::start()
params
.
push_back
(
"-y"
);
params
.
push_back
(
_output
);
std
::
string
cli
;
if
(
true
)
{
int
pparam_size
=
8
*
1024
;
char
*
pparam
=
new
char
[
pparam_size
];
char
*
p
=
pparam
;
char
*
last
=
pparam
+
pparam_size
;
for
(
int
i
=
0
;
i
<
(
int
)
params
.
size
();
i
++
)
{
std
::
string
ffp
=
params
[
i
];
snprintf
(
p
,
last
-
p
,
"%s "
,
ffp
.
c_str
());
p
+=
ffp
.
length
()
+
1
;
cli
+=
ffp
;
if
(
i
<
(
int
)
params
.
size
()
-
1
)
{
cli
+=
" "
;
}
}
srs_trace
(
"start transcoder, log: %s, params: %s"
,
log_file
.
c_str
(),
pparam
);
srs_freep
(
pparam
);
srs_trace
(
"start ffmpeg, log: %s, params: %s"
,
log_file
.
c_str
(),
cli
.
c_str
());
}
// for log
int
cid
=
_srs_context
->
get_id
();
// TODO: fork or vfork?
if
((
pid
=
fork
())
<
0
)
{
ret
=
ERROR_ENCODER_FORK
;
...
...
@@ -392,6 +399,19 @@ int SrsFFMPEG::start()
srs_error
(
"open encoder file %s failed. ret=%d"
,
log_file
.
c_str
(),
ret
);
return
ret
;
}
// log basic info
if
(
true
)
{
char
buf
[
4096
];
int
pos
=
0
;
pos
+=
snprintf
(
buf
+
pos
,
sizeof
(
buf
)
-
pos
,
"
\n
"
);
pos
+=
snprintf
(
buf
+
pos
,
sizeof
(
buf
)
-
pos
,
"ffmpeg cid=%d
\n
"
,
cid
);
pos
+=
snprintf
(
buf
+
pos
,
sizeof
(
buf
)
-
pos
,
"log=%s
\n
"
,
log_file
.
c_str
());
pos
+=
snprintf
(
buf
+
pos
,
sizeof
(
buf
)
-
pos
,
"params: %s
\n
"
,
cli
.
c_str
());
::
write
(
log_fd
,
buf
,
pos
);
}
// dup to stdout and stderr.
if
(
dup2
(
log_fd
,
STDOUT_FILENO
)
<
0
)
{
ret
=
ERROR_ENCODER_DUP2
;
srs_error
(
"dup2 encoder file failed. ret=%d"
,
ret
);
...
...
@@ -402,6 +422,7 @@ int SrsFFMPEG::start()
srs_error
(
"dup2 encoder file failed. ret=%d"
,
ret
);
return
ret
;
}
// close log fd
::
close
(
log_fd
);
// close other fds
...
...
trunk/src/core/srs_core.hpp
查看文件 @
5a95d59
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR "0"
#define VERSION_MINOR "9"
#define VERSION_REVISION "18
5
"
#define VERSION_REVISION "18
6
"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
...
...
请
注册
或
登录
后发表评论