stream.js 804 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. var childProcess = require('child_process');
  3. var path = require('path');
  4. var os = require('os');
  5. /**
  6. * Streams the video to disk.
  7. * @param {string} rtmpUrl
  8. * @param {string} rtmpInputPath
  9. * @param {string} swfUrl
  10. * @param {string} filePath
  11. * @param {function(Error)} done
  12. */
  13. module.exports = function(rtmpUrl, rtmpInputPath, swfUrl, filePath, done) {
  14. childProcess.exec(_command() + ' ' +
  15. '-r "' + rtmpUrl + '" ' +
  16. '-y "' + rtmpInputPath + '" ' +
  17. '-W "' + swfUrl + '" ' +
  18. '-o "' + filePath + '"', {
  19. maxBuffer: Infinity
  20. }, done);
  21. };
  22. /**
  23. * Determines the command for the operating system.
  24. * @private
  25. * @returns {string}
  26. */
  27. function _command() {
  28. if (os.platform() !== 'win32') return 'rtmpdump';
  29. return path.join(__dirname, '../../bin/rtmpdump.exe');
  30. }