From c61c2a939fffb13f33298645f44ef4e3b4fe33d3 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 11 Mar 2020 19:33:55 +0800 Subject: [PATCH] For #1634, refactor output with datetime for ingest/encoder/exec. 3.0.125 --- README.md | 1 + trunk/conf/full.conf | 30 ++++++++++++++++++++++++++++ trunk/src/app/srs_app_ingest.cpp | 1 + trunk/src/app/srs_app_ng_exec.cpp | 2 ++ trunk/src/core/srs_core_version3.hpp | 2 +- 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c5ef948659..ae034b22dc 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-03-11, For [#1634][bug #1634], refactor output with datetime for ingest/encoder/exec. 3.0.125 * v3.0, 2020-03-11, For [#1634][bug #1634], fix quit by accident SIGTERM while killing FFMPEG. 3.0.124 * v3.0, 2020-03-05, [3.0 beta2(3.0.123)][r3.0b2] released. 122170 lines. * v3.0, 2020-02-21, For [#1598][bug #1598], support SLB health checking by TCP. 3.0.123 diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index b56f27fbc1..f25a84073b 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -978,6 +978,16 @@ vhost exec.srs.com { # [tcUrl] the client request tcUrl. # [swfUrl] the client request swfUrl. # [pageUrl] the client request pageUrl. + # we also support datetime variables. + # [2006], replace this const to current year. + # [01], replace this const to current month. + # [02], replace this const to current date. + # [15], replace this const to current hour. + # [04], replace this const to current minute. + # [05], replace this const to current second. + # [999], replace this const to current millisecond. + # [timestamp],replace this const to current UNIX timestamp in ms. + # @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]" # @remark empty to ignore this exec. publish ./objs/ffmpeg/bin/ffmpeg -f flv -i [url] -c copy -y ./[stream].flv; } @@ -1331,6 +1341,16 @@ vhost ingest.srs.com { # output stream. variables: # [vhost] current vhost which start the ingest. # [port] system RTMP stream port. + # we also support datetime variables. + # [2006], replace this const to current year. + # [01], replace this const to current month. + # [02], replace this const to current date. + # [15], replace this const to current hour. + # [04], replace this const to current minute. + # [05], replace this const to current second. + # [999], replace this const to current millisecond. + # [timestamp],replace this const to current UNIX timestamp in ms. + # @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]" output rtmp://127.0.0.1:[port]/live?vhost=[vhost]/livestream; } } @@ -1519,6 +1539,16 @@ vhost example.transcode.srs.com { # [app] the input stream app. # [stream] the input stream name. # [engine] the transcode engine name. + # we also support datetime variables. + # [2006], replace this const to current year. + # [01], replace this const to current month. + # [02], replace this const to current date. + # [15], replace this const to current hour. + # [04], replace this const to current minute. + # [05], replace this const to current second. + # [999], replace this const to current millisecond. + # [timestamp],replace this const to current UNIX timestamp in ms. + # @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]" output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; } } diff --git a/trunk/src/app/srs_app_ingest.cpp b/trunk/src/app/srs_app_ingest.cpp index c98ed7d040..addbd9bc2c 100644 --- a/trunk/src/app/srs_app_ingest.cpp +++ b/trunk/src/app/srs_app_ingest.cpp @@ -382,6 +382,7 @@ srs_error_t SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* // ie. rtmp://localhost:1935/live/livestream_sd output = srs_string_replace(output, "[vhost]", vhost->arg0()); output = srs_string_replace(output, "[port]", srs_int2str(port)); + output = srs_path_build_timestamp(output); if (output.empty()) { return srs_error_new(ERROR_ENCODER_NO_OUTPUT, "empty output url, ingest=%s", ingest->arg0().c_str()); } diff --git a/trunk/src/app/srs_app_ng_exec.cpp b/trunk/src/app/srs_app_ng_exec.cpp index a1e613c8e3..17941a00c1 100644 --- a/trunk/src/app/srs_app_ng_exec.cpp +++ b/trunk/src/app/srs_app_ng_exec.cpp @@ -219,6 +219,8 @@ string SrsNgExec::parse(SrsRequest* req, string tmpl) output = srs_string_replace(output, "[tcUrl]", req->tcUrl); output = srs_string_replace(output, "[swfUrl]", req->swfUrl); output = srs_string_replace(output, "[pageUrl]", req->pageUrl); + + output = srs_path_build_timestamp(output); if (output.find("[url]") != string::npos) { string url = srs_generate_rtmp_url(req->host, req->port, req->host, req->vhost, req->app, req->stream, req->param); diff --git a/trunk/src/core/srs_core_version3.hpp b/trunk/src/core/srs_core_version3.hpp index 982408222b..8a69c55d2f 100644 --- a/trunk/src/core/srs_core_version3.hpp +++ b/trunk/src/core/srs_core_version3.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION3_HPP #define SRS_CORE_VERSION3_HPP -#define SRS_VERSION3_REVISION 124 +#define SRS_VERSION3_REVISION 125 #endif