winlin

for #711, support prefile for transcode. 3.0.12

@@ -174,6 +174,7 @@ Please select your language: @@ -174,6 +174,7 @@ Please select your language:
174 - [x] [experiment] Support push POST FLV over HTTP, please read [wiki]([CN][v2_CN_Streamer2], [EN][v2_EN_Streamer2]). 174 - [x] [experiment] Support push POST FLV over HTTP, please read [wiki]([CN][v2_CN_Streamer2], [EN][v2_EN_Streamer2]).
175 - [x] [experiment] Support multiple processes by [dolphin][srs-dolphin] or [oryx][oryx]. 175 - [x] [experiment] Support multiple processes by [dolphin][srs-dolphin] or [oryx][oryx].
176 - [x] [experiment] Support [mgmt console][console], please read [srs-ngb][srs-ngb]. 176 - [x] [experiment] Support [mgmt console][console], please read [srs-ngb][srs-ngb].
  177 +- [ ] Enhanced HLS audio-only use aac instead of ts.
177 - [ ] Enhanced forward with vhost and url variables. 178 - [ ] Enhanced forward with vhost and url variables.
178 - [ ] Support source or idle stream cleanup. 179 - [ ] Support source or idle stream cleanup.
179 - [ ] Support origin cluster, please read [#464][bug #464], [RTMP 302][bug #92]. 180 - [ ] Support origin cluster, please read [#464][bug #464], [RTMP 302][bug #92].
@@ -183,6 +184,7 @@ Please select your language: @@ -183,6 +184,7 @@ Please select your language:
183 184
184 ### V3 changes 185 ### V3 changes
185 186
  187 +* v3.0, 2017-01-06, for [#711][bug #711] support perfile for transcode. 3.0.12
186 * v3.0, 2017-01-05, patch ST for valgrind and ARM. 3.0.11 188 * v3.0, 2017-01-05, patch ST for valgrind and ARM. 3.0.11
187 * v3.0, 2017-01-05, for [#324][bug #324], always enable hstrs. 3.0.10 189 * v3.0, 2017-01-05, for [#324][bug #324], always enable hstrs. 3.0.10
188 * v3.0, 2016-12-15, fix [#717][bug #717], [#691][bug #691], http api/static/stream support cors. 3.0.9 190 * v3.0, 2016-12-15, fix [#717][bug #717], [#691][bug #691], http api/static/stream support cors. 3.0.9
@@ -1304,6 +1306,7 @@ Winlin @@ -1304,6 +1306,7 @@ Winlin
1304 [bug #511]: https://github.com/ossrs/srs/issues/511 1306 [bug #511]: https://github.com/ossrs/srs/issues/511
1305 [bug #717]: https://github.com/ossrs/srs/issues/717 1307 [bug #717]: https://github.com/ossrs/srs/issues/717
1306 [bug #691]: https://github.com/ossrs/srs/issues/691 1308 [bug #691]: https://github.com/ossrs/srs/issues/691
  1309 +[bug #711]: https://github.com/ossrs/srs/issues/711
1307 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx 1310 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx
1308 1311
1309 [exo #828]: https://github.com/google/ExoPlayer/pull/828 1312 [exo #828]: https://github.com/google/ExoPlayer/pull/828
1 -console*.conf  
2 -doc/frozen.2Mbps.1644x1028.flv  
3 -doc/frozen.500Kbps.766x480.flv  
4 -doc/kungfupanda3-tlr1_h1080p.200kbps.flv  
5 -doc/kungfupanda3-tlr1_h1080p.300kbps.flv  
6 -doc/kungfupanda3-tlr1_h1080p.400kbps.flv  
7 -doc/kungfupanda3-tlr1_h1080p.500kbps.flv  
8 -doc/kungfupanda3-tlr1_h1080p.600kbps.flv  
9 -doc/kungfupanda3-tlr1_h1080p.700kbps.flv  
10 -doc/kungfupanda3-tlr1_h1080p.800kbps.flv  
11 -doc/kungfupanda3-tlr1_h1080p.8mbps.flv  
12 -doc/kungfupanda3-tlr1_h1080p.900kbps.flv  
13 -doc/time.300kbps.flv  
14 -edge.conf 1 +*.conf
  2 +doc/frozen*.flv
  3 +doc/kungfupanda*.flv
  4 +doc/time*.flv
15 html 5 html
16 ide/srs_xcode/srs_xcode.xcodeproj/project.xcworkspace/xcshareddata/ 6 ide/srs_xcode/srs_xcode.xcodeproj/project.xcworkspace/xcshareddata/
17 ide/srs_xcode/srs_xcode.xcodeproj/project.xcworkspace/xcuserdata/ 7 ide/srs_xcode/srs_xcode.xcodeproj/project.xcworkspace/xcuserdata/
18 ide/srs_xcode/srs_xcode.xcodeproj/xcuserdata/ 8 ide/srs_xcode/srs_xcode.xcodeproj/xcuserdata/
19 -ingest.conf  
20 -origin.conf  
21 research/aac/ 9 research/aac/
22 -research/api-server/.idea/ 10 +.idea/
23 research/api-server/static-dir/mse 11 research/api-server/static-dir/mse
24 research/bat/ 12 research/bat/
25 research/big/ 13 research/big/
@@ -33,10 +21,8 @@ research/golang/temp.flv @@ -33,10 +21,8 @@ research/golang/temp.flv
33 research/librtmp/720p.h264.raw 21 research/librtmp/720p.h264.raw
34 research/librtmp/test.h264 22 research/librtmp/test.h264
35 research/licenser/ 23 research/licenser/
36 -research/players/.idea/  
37 research/players/fls_player/ 24 research/players/fls_player/
38 research/players/mic/ 25 research/players/mic/
39 -research/players/srs_player/.idea/  
40 research/proxy/ 26 research/proxy/
41 research/redis-ocluster/ 27 research/redis-ocluster/
42 research/rtmfp/ 28 research/rtmfp/
@@ -1277,14 +1277,29 @@ vhost example.transcode.srs.com { @@ -1277,14 +1277,29 @@ vhost example.transcode.srs.com {
1277 # the transcode engine for matched stream. 1277 # the transcode engine for matched stream.
1278 # all matched stream will transcoded to the following stream. 1278 # all matched stream will transcoded to the following stream.
1279 # the transcode set name(ie. hd) is optional and not used. 1279 # the transcode set name(ie. hd) is optional and not used.
  1280 + # we will build the parameters to fork ffmpeg:
  1281 + # ffmpeg <perfile>
  1282 + # -i <iformat>
  1283 + # <vfilter>
  1284 + # -vcodec <vcodec> -b:v <vbitrate> -r <vfps> -s <vwidth>x<vheight> -profile:v <vprofile> -preset <vpreset>
  1285 + # <vparams>
  1286 + # -acodec <acodec> -b:a <abitrate> -ar <asample_rate> -ac <achannels>
  1287 + # <aparams>
  1288 + # -f <oformat>
  1289 + # -y <output>
1280 engine example { 1290 engine example {
1281 # whether the engine is enabled 1291 # whether the engine is enabled
1282 # default: off. 1292 # default: off.
1283 enabled on; 1293 enabled on;
1284 - # input format, "ffmpeg -i", can be:  
1285 - # off, do not specifies the format, ffmpeg will guess it.  
1286 - # flv, for flv or RTMP stream.  
1287 - # other format, for example, mp4/aac whatever. 1294 + # pre-file options, before "-i"
  1295 + perfile {
  1296 + re;
  1297 + rtsp_transport tcp;
  1298 + }
  1299 + # input format "-i", can be:
  1300 + # off, do not specifies the format, ffmpeg will guess it.
  1301 + # flv, for flv or RTMP stream.
  1302 + # other format, for example, mp4/aac whatever.
1288 # default: flv 1303 # default: flv
1289 iformat flv; 1304 iformat flv;
1290 # ffmpeg filters, between "-i" and "-vcodec" 1305 # ffmpeg filters, between "-i" and "-vcodec"
@@ -3982,7 +3982,7 @@ int SrsConfig::check_config() @@ -3982,7 +3982,7 @@ int SrsConfig::check_config()
3982 && e != "vbitrate" && e != "vfps" && e != "vwidth" && e != "vheight" 3982 && e != "vbitrate" && e != "vfps" && e != "vwidth" && e != "vheight"
3983 && e != "vthreads" && e != "vprofile" && e != "vpreset" && e != "vparams" 3983 && e != "vthreads" && e != "vprofile" && e != "vpreset" && e != "vparams"
3984 && e != "acodec" && e != "abitrate" && e != "asample_rate" && e != "achannels" 3984 && e != "acodec" && e != "abitrate" && e != "asample_rate" && e != "achannels"
3985 - && e != "aparams" && e != "output" 3985 + && e != "aparams" && e != "output" && e != "perfile"
3986 && e != "iformat" && e != "oformat" 3986 && e != "iformat" && e != "oformat"
3987 ) { 3987 ) {
3988 ret = ERROR_SYSTEM_CONFIG_INVALID; 3988 ret = ERROR_SYSTEM_CONFIG_INVALID;
@@ -5377,6 +5377,41 @@ bool SrsConfig::get_engine_enabled(SrsConfDirective* conf) @@ -5377,6 +5377,41 @@ bool SrsConfig::get_engine_enabled(SrsConfDirective* conf)
5377 return SRS_CONF_PERFER_FALSE(conf->arg0()); 5377 return SRS_CONF_PERFER_FALSE(conf->arg0());
5378 } 5378 }
5379 5379
  5380 +string srs_prefix_underscores_ifno(string name)
  5381 +{
  5382 + if (srs_string_starts_with(name, "-")) {
  5383 + return name;
  5384 + } else {
  5385 + return "-" + name;
  5386 + }
  5387 +}
  5388 +
  5389 +vector<string> SrsConfig::get_engine_perfile(SrsConfDirective* conf)
  5390 +{
  5391 + vector<string> perfile;
  5392 +
  5393 + if (!conf) {
  5394 + return perfile;
  5395 + }
  5396 +
  5397 + conf = conf->get("perfile");
  5398 + if (!conf) {
  5399 + return perfile;
  5400 + }
  5401 +
  5402 + for (int i = 0; i < (int)conf->directives.size(); i++) {
  5403 + SrsConfDirective* option = conf->directives[i];
  5404 + if (!option) {
  5405 + continue;
  5406 + }
  5407 +
  5408 + perfile.push_back(srs_prefix_underscores_ifno(option->name));
  5409 + perfile.push_back(option->arg0());
  5410 + }
  5411 +
  5412 + return perfile;
  5413 +}
  5414 +
5380 string SrsConfig::get_engine_iformat(SrsConfDirective* conf) 5415 string SrsConfig::get_engine_iformat(SrsConfDirective* conf)
5381 { 5416 {
5382 static string DEFAULT = "flv"; 5417 static string DEFAULT = "flv";
@@ -5412,7 +5447,7 @@ vector<string> SrsConfig::get_engine_vfilter(SrsConfDirective* conf) @@ -5412,7 +5447,7 @@ vector<string> SrsConfig::get_engine_vfilter(SrsConfDirective* conf)
5412 continue; 5447 continue;
5413 } 5448 }
5414 5449
5415 - vfilter.push_back("-" + filter->name); 5450 + vfilter.push_back(srs_prefix_underscores_ifno(filter->name));
5416 vfilter.push_back(filter->arg0()); 5451 vfilter.push_back(filter->arg0());
5417 } 5452 }
5418 5453
@@ -5566,7 +5601,7 @@ vector<string> SrsConfig::get_engine_vparams(SrsConfDirective* conf) @@ -5566,7 +5601,7 @@ vector<string> SrsConfig::get_engine_vparams(SrsConfDirective* conf)
5566 continue; 5601 continue;
5567 } 5602 }
5568 5603
5569 - vparams.push_back("-" + filter->name); 5604 + vparams.push_back(srs_prefix_underscores_ifno(filter->name));
5570 vparams.push_back(filter->arg0()); 5605 vparams.push_back(filter->arg0());
5571 } 5606 }
5572 5607
@@ -5656,7 +5691,7 @@ vector<string> SrsConfig::get_engine_aparams(SrsConfDirective* conf) @@ -5656,7 +5691,7 @@ vector<string> SrsConfig::get_engine_aparams(SrsConfDirective* conf)
5656 continue; 5691 continue;
5657 } 5692 }
5658 5693
5659 - aparams.push_back("-" + filter->name); 5694 + aparams.push_back(srs_prefix_underscores_ifno(filter->name));
5660 aparams.push_back(filter->arg0()); 5695 aparams.push_back(filter->arg0());
5661 } 5696 }
5662 5697
@@ -977,6 +977,10 @@ public: @@ -977,6 +977,10 @@ public:
977 */ 977 */
978 virtual bool get_engine_enabled(SrsConfDirective* conf); 978 virtual bool get_engine_enabled(SrsConfDirective* conf);
979 /** 979 /**
  980 + * get the perfile of engine
  981 + */
  982 + virtual std::vector<std::string> get_engine_perfile(SrsConfDirective* conf);
  983 + /**
980 * get the iformat of engine 984 * get the iformat of engine
981 */ 985 */
982 virtual std::string get_engine_iformat(SrsConfDirective* conf); 986 virtual std::string get_engine_iformat(SrsConfDirective* conf);
@@ -112,6 +112,7 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine) @@ -112,6 +112,7 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine)
112 { 112 {
113 int ret = ERROR_SUCCESS; 113 int ret = ERROR_SUCCESS;
114 114
  115 + perfile = _srs_config->get_engine_perfile(engine);
115 iformat = _srs_config->get_engine_iformat(engine); 116 iformat = _srs_config->get_engine_iformat(engine);
116 vfilter = _srs_config->get_engine_vfilter(engine); 117 vfilter = _srs_config->get_engine_vfilter(engine);
117 vcodec = _srs_config->get_engine_vcodec(engine); 118 vcodec = _srs_config->get_engine_vcodec(engine);
@@ -264,6 +265,17 @@ int SrsFFMPEG::start() @@ -264,6 +265,17 @@ int SrsFFMPEG::start()
264 params.push_back(_iparams); 265 params.push_back(_iparams);
265 } 266 }
266 267
  268 + // build the perfile
  269 + if (!perfile.empty()) {
  270 + std::vector<std::string>::iterator it;
  271 + for (it = perfile.begin(); it != perfile.end(); ++it) {
  272 + std::string p = *it;
  273 + if (!p.empty()) {
  274 + params.push_back(p);
  275 + }
  276 + }
  277 + }
  278 +
267 // input. 279 // input.
268 if (iformat != "off" && !iformat.empty()) { 280 if (iformat != "off" && !iformat.empty()) {
269 params.push_back("-f"); 281 params.push_back("-f");
@@ -51,6 +51,7 @@ private: @@ -51,6 +51,7 @@ private:
51 private: 51 private:
52 std::string ffmpeg; 52 std::string ffmpeg;
53 std::string _iparams; 53 std::string _iparams;
  54 + std::vector<std::string> perfile;
54 std::string iformat; 55 std::string iformat;
55 std::string input; 56 std::string input;
56 std::vector<std::string> vfilter; 57 std::vector<std::string> vfilter;
@@ -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 11 34 +#define VERSION_REVISION 12
35 35
36 // generated by configure, only macros. 36 // generated by configure, only macros.
37 #include <srs_auto_headers.hpp> 37 #include <srs_auto_headers.hpp>