SHARE
TWEET

Untitled

a guest Jul 11th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fs = require('fs');
  2. var ffmpeg = require('ffmpeg-static');
  3. const os = require('os');
  4. console.log(ffmpeg.path);
  5. const { spawn } = require('child_process');
  6. const Writable = require('stream').Writable;
  7.  
  8. const fpath = __dirname + "/uno.mp4"
  9. const resultpath = __dirname + "/out.png"
  10. const arguments = `-i pipe: -ss 00:00:02 -vframes 1 ${resultpath}`
  11. const child = spawn(ffmpeg.path, arguments.split(' '), {
  12.     cwd: os.tmpdir(),
  13. });
  14.  
  15. child.stdin.on('error', (...arg) => {
  16.     console.log('error', arg);
  17. });
  18.  
  19. child.on('exit', code => {
  20.     console.log('exit', code);
  21. });
  22.  
  23. child.stdout.on('data', (data) => {
  24.     console.log(`stdout: ${data}`);
  25. });
  26.  
  27. child.stderr.on('data', (data) => {
  28.     console.log(`stderr: ${data}`);
  29. });
  30.  
  31.  
  32. const readable = fs.createReadStream(__dirname + '/uno.mp4');
  33. readable.on('data', (chunk) => {
  34.     console.log(`Received ${chunk.length} bytes of data.`);
  35.     child.stdin.write(chunk);
  36. });
  37. readable.on('end', () => {
  38.     console.log('There will be no more data.');
  39.     child.stdin.end()
  40. });
  41.  
  42. // readable.pipe(child.stdin);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top