stream.ts 707 B

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