From 29122b6e70ce8bb0e63334bc29734614ae525352 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 20 Oct 2015 14:52:34 +0800 Subject: [PATCH] fix #502, transcoder support snapshot. --- README.md | 2 ++ trunk/conf/full.conf | 2 ++ trunk/src/app/srs_app_encoder.cpp | 2 +- trunk/src/app/srs_app_ffmpeg.cpp | 33 ++++++++++++++++++------------- trunk/src/app/srs_app_process.cpp | 5 +++-- trunk/src/core/srs_core.hpp | 2 +- 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b39099159..bcc448428 100755 --- a/README.md +++ b/README.md @@ -386,6 +386,7 @@ Remark: ### History +* v3.0, 2015-10-20, fix [#502][bug #502], support snapshot with http-callback or transcoder. 3.0.5 * v3.0, 2015-09-19, support amf0 and json to convert with each other. * v3.0, 2015-09-19, json objects support dumps to string. * v3.0, 2015-09-14, fix [#459][bug #459], support dvr raw api. 3.0.4 @@ -1277,6 +1278,7 @@ Winlin [bug #299]: https://github.com/simple-rtmp-server/srs/issues/299 [bug #466]: https://github.com/simple-rtmp-server/srs/issues/466 [bug #468]: https://github.com/simple-rtmp-server/srs/issues/468 +[bug #502]: https://github.com/simple-rtmp-server/srs/issues/502 [bug #xxxxxxx]: https://github.com/simple-rtmp-server/srs/issues/xxxxxxx [r2.0a2]: https://github.com/simple-rtmp-server/srs/releases/tag/2.0a2 diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index e2c6ae406..1ebc28790 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -1281,6 +1281,7 @@ vhost example.transcode.srs.com { # video encoder name, "ffmpeg -vcodec" # can be: # libx264: use h.264(libx264) video encoder. + # png: use png to snapshot thumbnail. # copy: donot encoder the video stream, copy it. # vn: disable video output. vcodec libx264; @@ -1354,6 +1355,7 @@ vhost example.transcode.srs.com { # output format, "ffmpeg -f" can be: # off, do not specifies the format, ffmpeg will guess it. # flv, for flv or RTMP stream. + # image2, for vcodec png to snapshot thumbnail. # other format, for example, mp4/aac whatever. # default: flv oformat flv; diff --git a/trunk/src/app/srs_app_encoder.cpp b/trunk/src/app/srs_app_encoder.cpp index ed25f6e5f..46a696b53 100644 --- a/trunk/src/app/srs_app_encoder.cpp +++ b/trunk/src/app/srs_app_encoder.cpp @@ -262,7 +262,7 @@ int SrsEncoder::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, SrsConfDir input = "rtmp://"; input += SRS_CONSTS_LOCALHOST; input += ":"; - input += req->port; + input += srs_int2str(req->port); input += "/"; input += req->app; input += "?vhost="; diff --git a/trunk/src/app/srs_app_ffmpeg.cpp b/trunk/src/app/srs_app_ffmpeg.cpp index e7843057d..cb28f0479 100644 --- a/trunk/src/app/srs_app_ffmpeg.cpp +++ b/trunk/src/app/srs_app_ffmpeg.cpp @@ -47,16 +47,17 @@ using namespace std; #ifdef SRS_AUTO_FFMPEG_STUB -#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 "libx264" +#define SRS_RTMP_ENCODER_VCODEC_PNG "png" // any aac encoder is ok which contains the aac, // for example, libaacplus, aac, fdkaac -#define SRS_RTMP_ENCODER_ACODEC "aac" -#define SRS_RTMP_ENCODER_LIBAACPLUS "libaacplus" -#define SRS_RTMP_ENCODER_LIBFDKAAC "libfdk_aac" +#define SRS_RTMP_ENCODER_ACODEC "aac" +#define SRS_RTMP_ENCODER_LIBAACPLUS "libaacplus" +#define SRS_RTMP_ENCODER_LIBFDKAAC "libfdk_aac" SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin) { @@ -139,11 +140,11 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine) return ret; } - if (vcodec != SRS_RTMP_ENCODER_COPY && vcodec != SRS_RTMP_ENCODER_NO_VIDEO) { - if (vcodec != SRS_RTMP_ENCODER_VCODEC) { + if (vcodec != SRS_RTMP_ENCODER_COPY && vcodec != SRS_RTMP_ENCODER_NO_VIDEO && vcodec != SRS_RTMP_ENCODER_VCODEC_PNG) { + if (vcodec != SRS_RTMP_ENCODER_VCODEC_LIBX264) { ret = ERROR_ENCODER_VCODEC; srs_error("invalid vcodec, must be %s, actual %s, ret=%d", - SRS_RTMP_ENCODER_VCODEC, vcodec.c_str(), ret); + SRS_RTMP_ENCODER_VCODEC_LIBX264, vcodec.c_str(), ret); return ret; } if (vbitrate < 0) { @@ -319,11 +320,15 @@ int SrsFFMPEG::start() params.push_back(srs_int2str(vthreads)); } - params.push_back("-profile:v"); - params.push_back(vprofile); + if (!vprofile.empty()) { + params.push_back("-profile:v"); + params.push_back(vprofile); + } - params.push_back("-preset"); - params.push_back(vpreset); + if (!vpreset.empty()) { + params.push_back("-preset"); + params.push_back(vpreset); + } // vparams if (!vparams.empty()) { diff --git a/trunk/src/app/srs_app_process.cpp b/trunk/src/app/srs_app_process.cpp index 0e8e26205..c2b1f0332 100644 --- a/trunk/src/app/srs_app_process.cpp +++ b/trunk/src/app/srs_app_process.cpp @@ -76,15 +76,16 @@ int SrsProcess::initialize(string binary, vector argv) for (int i = 0; i < (int)argv.size(); i++) { std::string ffp = argv[i]; + std::string nffp = (i < (int)argv.size() -1)? argv[i + 1] : ""; // remove the stdout and stderr. - if (ffp == "1") { + if (ffp == "1" && nffp == ">") { if (i + 2 < (int)argv.size()) { stdout_file = argv[i + 2]; i += 2; } continue; - } else if (ffp == "2") { + } else if (ffp == "2" && nffp == ">") { if (i + 2 < (int)argv.size()) { stderr_file = argv[i + 2]; i += 2; diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 1441b2ca5..56e43471b 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 4 +#define VERSION_REVISION 5 // server info. #define RTMP_SIG_SRS_KEY "SRS"