stream.js 801 B

12345678910111213141516171819202122232425262728293031
  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 using rtmpdump.
  7. * @param {string} rtmpUrl
  8. * @param {string} inputPath
  9. * @param {string} swfUrl
  10. * @param {string} outputPath
  11. * @param {function(Error)} done
  12. */
  13. module.exports = function(rtmpUrl, inputPath, swfUrl, outputPath, done) {
  14. childProcess.exec(_command() + ' ' +
  15. '-r "' + rtmpUrl + '" ' +
  16. '-y "' + inputPath + '" ' +
  17. '-W "' + swfUrl + '" ' +
  18. '-o "' + outputPath + '"', {
  19. maxBuffer: Infinity
  20. }, done);
  21. };
  22. /**
  23. * Determines the command for the operating system.
  24. * @returns {string}
  25. */
  26. function _command() {
  27. if (os.platform() !== 'win32') return 'rtmpdump';
  28. return path.join(__dirname, '../../bin/rtmpdump.exe');
  29. }