Skip to content

Instantly share code, notes, and snippets.

@ralphtheninja
Created March 3, 2013 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralphtheninja/5078496 to your computer and use it in GitHub Desktop.
Save ralphtheninja/5078496 to your computer and use it in GitHub Desktop.
node v0.9.11 stream problems. My video file is 350Mb large. Mplayer starts up but stops after a while (like 10 seconds). It seems that child.stdin is not emitting 'ondrain', but I'm not 100% sure. If I copy the data with createReadStream/createWriteStream it works. Works fine on v0.8.19
#!/usr/bin/env node
// This works just fine.
var fs = require('fs')
, from = fs.createReadStream('./video')
, to = fs.createWriteStream('./video-copy')
from.pipe(to)
#!/usr/bin/env node
// This works for a while.
var spawn = require('child_process').spawn
, child = spawn('mplayer', ['-'])
, movie = require('fs').createReadStream('./video')
movie.pipe(child.stdin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment