stream.ts 698 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. export = main;
  3. import childProcess = require('child_process');
  4. import path = require('path');
  5. import os = require('os');
  6. /**
  7. * Streams the video to disk.
  8. */
  9. function main(rtmpUrl: string, rtmpInputPath: string, swfUrl: string, filePath: string, done: (err: Error) => void) {
  10. childProcess.exec(command() + ' ' +
  11. '-r "' + rtmpUrl + '" ' +
  12. '-y "' + rtmpInputPath + '" ' +
  13. '-W "' + swfUrl + '" ' +
  14. '-o "' + filePath + '"', {
  15. maxBuffer: Infinity
  16. }, done);
  17. }
  18. /**
  19. * Determines the command for the operating system.
  20. */
  21. function command(): string {
  22. if (os.platform() !== 'win32') return 'rtmpdump';
  23. return path.join(__dirname, '../../bin/rtmpdump.exe');
  24. }