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
2013-11-30 21:53:28 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
06278176ddfeb215c134d9cf475ffb5ce1ffa8e5
06278176
1 parent
80a81b16
add research empty ffmpeg
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
69 行增加
和
1 行删除
trunk/conf/srs.conf
trunk/src/core/srs_core_encoder.cpp
trunk/src/core/srs_core_encoder.hpp
trunk/src/core/srs_core_error.hpp
trunk/conf/srs.conf
查看文件 @
0627817
...
...
@@ -18,7 +18,7 @@ vhost __defaultVhost__ {
#forward 127.0.0.1:1936;
transcode
{
enabled
on
;
ffmpeg
.
/
objs
/
ffmpeg
/
bin
/
ffmpeg
;
ffmpeg
/
home
/
winlin
/
srs
/
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
fd
{
enabled
on
;
vcodec
libx264
;
...
...
trunk/src/core/srs_core_encoder.cpp
查看文件 @
0627817
...
...
@@ -23,6 +23,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_encoder.hpp>
#include <stdlib.h>
#include <unistd.h>
#include <srs_core_error.hpp>
#include <srs_core_log.hpp>
#include <srs_core_config.hpp>
...
...
@@ -35,6 +38,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SrsFFMPEG
::
SrsFFMPEG
(
std
::
string
ffmpeg_bin
)
{
started
=
false
;
pid
=
-
1
;
ffmpeg
=
ffmpeg_bin
;
vbitrate
=
0
;
...
...
@@ -75,6 +79,14 @@ int SrsFFMPEG::initialize(std::string vhost, std::string port, std::string app,
// ensure the size is even.
vwidth
-=
vwidth
%
2
;
vheight
-=
vheight
%
2
;
// input stream, from local.
input
=
"rtmp://127.0.0.1:"
;
input
+=
port
;
input
+=
"/"
;
input
+=
app
;
input
+=
"/"
;
input
+=
stream
;
if
(
vhost
==
RTMP_VHOST_DEFAULT
)
{
output
=
srs_replace
(
output
,
"[vhost]"
,
"127.0.0.1"
);
...
...
@@ -167,6 +179,59 @@ int SrsFFMPEG::start()
return
ret
;
}
// prepare execl params
char
vsize
[
22
];
snprintf
(
vsize
,
sizeof
(
vsize
),
"%dx%d"
,
vwidth
,
vheight
);
char
vaspect
[
22
];
snprintf
(
vaspect
,
sizeof
(
vaspect
),
"%d:%d"
,
vwidth
,
vheight
);
// we use vfork, for we use fored process
// to start ffmpeg, that is, exec after vfork.
if
((
pid
=
fork
())
<
0
)
{
ret
=
ERROR_ENCODER_FORK
;
srs_error
(
"vfork process failed. ret=%d"
,
ret
);
return
ret
;
}
// child process: ffmpeg encoder engine.
if
(
pid
==
0
)
{
// must exec immediately, or may introduce bug.
ret
=
execl
(
ffmpeg
.
c_str
(),
"-i"
,
input
.
c_str
(),
// video specified.
"-vcodec"
,
vcodec
.
c_str
(),
"-b:v"
,
vbitrate
*
1000
,
"-r"
,
vfps
,
"-size"
,
vsize
,
"-aspect"
,
vaspect
,
// TODO: add aspect if needed.
"-threads"
,
vthreads
,
"-profile"
,
vprofile
.
c_str
(),
"-preset"
,
vpreset
.
c_str
(),
vparams
.
c_str
(),
// audio specified.
"-acodec"
,
acodec
.
c_str
(),
"-b:a"
,
abitrate
*
1000
,
"-ar"
,
asample_rate
,
"-ac"
,
achannels
,
aparams
.
c_str
(),
"-f"
,
"flv"
,
"-y"
,
output
.
c_str
(),
NULL
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"fork ffmpeg failed, errno=%d(%s)"
,
errno
,
strerror
(
errno
));
}
exit
(
ret
);
}
// parent.
if
(
pid
>
0
)
{
started
=
true
;
srs_trace
(
"vfored ffmpeg encoder engine, pid=%d"
,
pid
);
return
ret
;
}
return
ret
;
}
...
...
trunk/src/core/srs_core_encoder.hpp
查看文件 @
0627817
...
...
@@ -44,6 +44,7 @@ class SrsFFMPEG
{
private
:
bool
started
;
pid_t
pid
;
private
:
std
::
string
ffmpeg
;
std
::
string
vcodec
;
...
...
@@ -61,6 +62,7 @@ private:
int
achannels
;
std
::
string
aparams
;
std
::
string
output
;
std
::
string
input
;
public
:
SrsFFMPEG
(
std
::
string
ffmpeg_bin
);
virtual
~
SrsFFMPEG
();
...
...
trunk/src/core/srs_core_error.hpp
查看文件 @
0627817
...
...
@@ -135,5 +135,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_ENCODER_VWIDTH 710
#define ERROR_ENCODER_VFPS 711
#define ERROR_ENCODER_VBITRATE 712
#define ERROR_ENCODER_FORK 713
#endif
\ No newline at end of file
...
...
请
注册
或
登录
后发表评论