winlin

fix #119: use iformat and oformat for ffmpeg transcode.

@@ -208,6 +208,7 @@ Supported operating systems and hardware: @@ -208,6 +208,7 @@ Supported operating systems and hardware:
208 * 2013-10-17, Created.<br/> 208 * 2013-10-17, Created.<br/>
209 209
210 ## History 210 ## History
  211 +* v1.0, 2014-07-19, fix [#119](https://github.com/winlinvip/simple-rtmp-server/issues/119), use iformat and oformat for ffmpeg transcode. 0.9.163.
211 * <strong>v1.0, 2014-07-13, [1.0 mainline6(0.9.160)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline8) released. 50029 lines.</strong> 212 * <strong>v1.0, 2014-07-13, [1.0 mainline6(0.9.160)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline8) released. 50029 lines.</strong>
212 * v1.0, 2014-07-13, refine the bandwidth check/test, add as/js library, use srs-librtmp for linux tool. 0.9.159 213 * v1.0, 2014-07-13, refine the bandwidth check/test, add as/js library, use srs-librtmp for linux tool. 0.9.159
213 * v1.0, 2014-07-12, complete rtmp stack utest. 0.9.156 214 * v1.0, 2014-07-12, complete rtmp stack utest. 0.9.156
@@ -76,6 +76,11 @@ void SrsFFMPEG::set_iparams(string iparams) @@ -76,6 +76,11 @@ void SrsFFMPEG::set_iparams(string iparams)
76 _iparams = iparams; 76 _iparams = iparams;
77 } 77 }
78 78
  79 +void SrsFFMPEG::set_oformat(string format)
  80 +{
  81 + oformat = format;
  82 +}
  83 +
79 string SrsFFMPEG::output() 84 string SrsFFMPEG::output()
80 { 85 {
81 return _output; 86 return _output;
@@ -243,7 +248,7 @@ int SrsFFMPEG::start() @@ -243,7 +248,7 @@ int SrsFFMPEG::start()
243 } 248 }
244 249
245 // input. 250 // input.
246 - if (iformat != "off") { 251 + if (iformat != "off" && !iformat.empty()) {
247 params.push_back("-f"); 252 params.push_back("-f");
248 params.push_back(iformat); 253 params.push_back(iformat);
249 } 254 }
@@ -346,7 +351,7 @@ int SrsFFMPEG::start() @@ -346,7 +351,7 @@ int SrsFFMPEG::start()
346 } 351 }
347 352
348 // output 353 // output
349 - if (oformat != "off") { 354 + if (oformat != "off" && !oformat.empty()) {
350 params.push_back("-f"); 355 params.push_back("-f");
351 params.push_back(oformat); 356 params.push_back(oformat);
352 } 357 }
@@ -75,6 +75,7 @@ public: @@ -75,6 +75,7 @@ public:
75 virtual ~SrsFFMPEG(); 75 virtual ~SrsFFMPEG();
76 public: 76 public:
77 virtual void set_iparams(std::string iparams); 77 virtual void set_iparams(std::string iparams);
  78 + virtual void set_oformat(std::string format);
78 virtual std::string output(); 79 virtual std::string output();
79 public: 80 public:
80 virtual int initialize(std::string in, std::string out, std::string log); 81 virtual int initialize(std::string in, std::string out, std::string log);
@@ -317,12 +317,14 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S @@ -317,12 +317,14 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S
317 ingest->arg0().c_str(), input_type.c_str(), ret); 317 ingest->arg0().c_str(), input_type.c_str(), ret);
318 } 318 }
319 319
  320 + // set output format to flv for RTMP
  321 + ffmpeg->set_oformat("flv");
  322 +
320 std::string vcodec = _srs_config->get_engine_vcodec(engine); 323 std::string vcodec = _srs_config->get_engine_vcodec(engine);
321 std::string acodec = _srs_config->get_engine_acodec(engine); 324 std::string acodec = _srs_config->get_engine_acodec(engine);
322 // whatever the engine config, use copy as default. 325 // whatever the engine config, use copy as default.
323 - if (!engine || vcodec.empty() || acodec.empty()  
324 - || !_srs_config->get_engine_enabled(engine)  
325 - ) { 326 + bool engine_disabled = !engine || !_srs_config->get_engine_enabled(engine);
  327 + if (engine_disabled || vcodec.empty() || acodec.empty()) {
326 if ((ret = ffmpeg->initialize_copy()) != ERROR_SUCCESS) { 328 if ((ret = ffmpeg->initialize_copy()) != ERROR_SUCCESS) {
327 return ret; 329 return ret;
328 } 330 }
@@ -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 "0" 32 #define VERSION_MAJOR "0"
33 #define VERSION_MINOR "9" 33 #define VERSION_MINOR "9"
34 -#define VERSION_REVISION "162" 34 +#define VERSION_REVISION "163"
35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION 35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"