winlin

fix #502, transcoder support snapshot.

@@ -386,6 +386,7 @@ Remark: @@ -386,6 +386,7 @@ Remark:
386 386
387 ### History 387 ### History
388 388
  389 +* v3.0, 2015-10-20, fix [#502][bug #502], support snapshot with http-callback or transcoder. 3.0.5
389 * v3.0, 2015-09-19, support amf0 and json to convert with each other. 390 * v3.0, 2015-09-19, support amf0 and json to convert with each other.
390 * v3.0, 2015-09-19, json objects support dumps to string. 391 * v3.0, 2015-09-19, json objects support dumps to string.
391 * v3.0, 2015-09-14, fix [#459][bug #459], support dvr raw api. 3.0.4 392 * v3.0, 2015-09-14, fix [#459][bug #459], support dvr raw api. 3.0.4
@@ -1277,6 +1278,7 @@ Winlin @@ -1277,6 +1278,7 @@ Winlin
1277 [bug #299]: https://github.com/simple-rtmp-server/srs/issues/299 1278 [bug #299]: https://github.com/simple-rtmp-server/srs/issues/299
1278 [bug #466]: https://github.com/simple-rtmp-server/srs/issues/466 1279 [bug #466]: https://github.com/simple-rtmp-server/srs/issues/466
1279 [bug #468]: https://github.com/simple-rtmp-server/srs/issues/468 1280 [bug #468]: https://github.com/simple-rtmp-server/srs/issues/468
  1281 +[bug #502]: https://github.com/simple-rtmp-server/srs/issues/502
1280 [bug #xxxxxxx]: https://github.com/simple-rtmp-server/srs/issues/xxxxxxx 1282 [bug #xxxxxxx]: https://github.com/simple-rtmp-server/srs/issues/xxxxxxx
1281 1283
1282 [r2.0a2]: https://github.com/simple-rtmp-server/srs/releases/tag/2.0a2 1284 [r2.0a2]: https://github.com/simple-rtmp-server/srs/releases/tag/2.0a2
@@ -1281,6 +1281,7 @@ vhost example.transcode.srs.com { @@ -1281,6 +1281,7 @@ vhost example.transcode.srs.com {
1281 # video encoder name, "ffmpeg -vcodec" 1281 # video encoder name, "ffmpeg -vcodec"
1282 # can be: 1282 # can be:
1283 # libx264: use h.264(libx264) video encoder. 1283 # libx264: use h.264(libx264) video encoder.
  1284 + # png: use png to snapshot thumbnail.
1284 # copy: donot encoder the video stream, copy it. 1285 # copy: donot encoder the video stream, copy it.
1285 # vn: disable video output. 1286 # vn: disable video output.
1286 vcodec libx264; 1287 vcodec libx264;
@@ -1354,6 +1355,7 @@ vhost example.transcode.srs.com { @@ -1354,6 +1355,7 @@ vhost example.transcode.srs.com {
1354 # output format, "ffmpeg -f" can be: 1355 # output format, "ffmpeg -f" can be:
1355 # off, do not specifies the format, ffmpeg will guess it. 1356 # off, do not specifies the format, ffmpeg will guess it.
1356 # flv, for flv or RTMP stream. 1357 # flv, for flv or RTMP stream.
  1358 + # image2, for vcodec png to snapshot thumbnail.
1357 # other format, for example, mp4/aac whatever. 1359 # other format, for example, mp4/aac whatever.
1358 # default: flv 1360 # default: flv
1359 oformat flv; 1361 oformat flv;
@@ -262,7 +262,7 @@ int SrsEncoder::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, SrsConfDir @@ -262,7 +262,7 @@ int SrsEncoder::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, SrsConfDir
262 input = "rtmp://"; 262 input = "rtmp://";
263 input += SRS_CONSTS_LOCALHOST; 263 input += SRS_CONSTS_LOCALHOST;
264 input += ":"; 264 input += ":";
265 - input += req->port; 265 + input += srs_int2str(req->port);
266 input += "/"; 266 input += "/";
267 input += req->app; 267 input += req->app;
268 input += "?vhost="; 268 input += "?vhost=";
@@ -47,16 +47,17 @@ using namespace std; @@ -47,16 +47,17 @@ using namespace std;
47 47
48 #ifdef SRS_AUTO_FFMPEG_STUB 48 #ifdef SRS_AUTO_FFMPEG_STUB
49 49
50 -#define SRS_RTMP_ENCODER_COPY "copy"  
51 -#define SRS_RTMP_ENCODER_NO_VIDEO "vn"  
52 -#define SRS_RTMP_ENCODER_NO_AUDIO "an" 50 +#define SRS_RTMP_ENCODER_COPY "copy"
  51 +#define SRS_RTMP_ENCODER_NO_VIDEO "vn"
  52 +#define SRS_RTMP_ENCODER_NO_AUDIO "an"
53 // only support libx264 encoder. 53 // only support libx264 encoder.
54 -#define SRS_RTMP_ENCODER_VCODEC "libx264" 54 +#define SRS_RTMP_ENCODER_VCODEC_LIBX264 "libx264"
  55 +#define SRS_RTMP_ENCODER_VCODEC_PNG "png"
55 // any aac encoder is ok which contains the aac, 56 // any aac encoder is ok which contains the aac,
56 // for example, libaacplus, aac, fdkaac 57 // for example, libaacplus, aac, fdkaac
57 -#define SRS_RTMP_ENCODER_ACODEC "aac"  
58 -#define SRS_RTMP_ENCODER_LIBAACPLUS "libaacplus"  
59 -#define SRS_RTMP_ENCODER_LIBFDKAAC "libfdk_aac" 58 +#define SRS_RTMP_ENCODER_ACODEC "aac"
  59 +#define SRS_RTMP_ENCODER_LIBAACPLUS "libaacplus"
  60 +#define SRS_RTMP_ENCODER_LIBFDKAAC "libfdk_aac"
60 61
61 SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin) 62 SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin)
62 { 63 {
@@ -139,11 +140,11 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine) @@ -139,11 +140,11 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine)
139 return ret; 140 return ret;
140 } 141 }
141 142
142 - if (vcodec != SRS_RTMP_ENCODER_COPY && vcodec != SRS_RTMP_ENCODER_NO_VIDEO) {  
143 - if (vcodec != SRS_RTMP_ENCODER_VCODEC) { 143 + if (vcodec != SRS_RTMP_ENCODER_COPY && vcodec != SRS_RTMP_ENCODER_NO_VIDEO && vcodec != SRS_RTMP_ENCODER_VCODEC_PNG) {
  144 + if (vcodec != SRS_RTMP_ENCODER_VCODEC_LIBX264) {
144 ret = ERROR_ENCODER_VCODEC; 145 ret = ERROR_ENCODER_VCODEC;
145 srs_error("invalid vcodec, must be %s, actual %s, ret=%d", 146 srs_error("invalid vcodec, must be %s, actual %s, ret=%d",
146 - SRS_RTMP_ENCODER_VCODEC, vcodec.c_str(), ret); 147 + SRS_RTMP_ENCODER_VCODEC_LIBX264, vcodec.c_str(), ret);
147 return ret; 148 return ret;
148 } 149 }
149 if (vbitrate < 0) { 150 if (vbitrate < 0) {
@@ -319,11 +320,15 @@ int SrsFFMPEG::start() @@ -319,11 +320,15 @@ int SrsFFMPEG::start()
319 params.push_back(srs_int2str(vthreads)); 320 params.push_back(srs_int2str(vthreads));
320 } 321 }
321 322
322 - params.push_back("-profile:v");  
323 - params.push_back(vprofile); 323 + if (!vprofile.empty()) {
  324 + params.push_back("-profile:v");
  325 + params.push_back(vprofile);
  326 + }
324 327
325 - params.push_back("-preset");  
326 - params.push_back(vpreset); 328 + if (!vpreset.empty()) {
  329 + params.push_back("-preset");
  330 + params.push_back(vpreset);
  331 + }
327 332
328 // vparams 333 // vparams
329 if (!vparams.empty()) { 334 if (!vparams.empty()) {
@@ -76,15 +76,16 @@ int SrsProcess::initialize(string binary, vector<string> argv) @@ -76,15 +76,16 @@ int SrsProcess::initialize(string binary, vector<string> argv)
76 76
77 for (int i = 0; i < (int)argv.size(); i++) { 77 for (int i = 0; i < (int)argv.size(); i++) {
78 std::string ffp = argv[i]; 78 std::string ffp = argv[i];
  79 + std::string nffp = (i < (int)argv.size() -1)? argv[i + 1] : "";
79 80
80 // remove the stdout and stderr. 81 // remove the stdout and stderr.
81 - if (ffp == "1") { 82 + if (ffp == "1" && nffp == ">") {
82 if (i + 2 < (int)argv.size()) { 83 if (i + 2 < (int)argv.size()) {
83 stdout_file = argv[i + 2]; 84 stdout_file = argv[i + 2];
84 i += 2; 85 i += 2;
85 } 86 }
86 continue; 87 continue;
87 - } else if (ffp == "2") { 88 + } else if (ffp == "2" && nffp == ">") {
88 if (i + 2 < (int)argv.size()) { 89 if (i + 2 < (int)argv.size()) {
89 stderr_file = argv[i + 2]; 90 stderr_file = argv[i + 2];
90 i += 2; 91 i += 2;
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR 3 32 #define VERSION_MAJOR 3
33 #define VERSION_MINOR 0 33 #define VERSION_MINOR 0
34 -#define VERSION_REVISION 4 34 +#define VERSION_REVISION 5
35 35
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"