Skip to content

Instantly share code, notes, and snippets.

@mizzy
Created October 28, 2011 15:29
Show Gist options
  • Save mizzy/1322541 to your computer and use it in GitHub Desktop.
Save mizzy/1322541 to your computer and use it in GitHub Desktop.
var spawn = require('child_process').spawn;
var input = 'test.aiff';
var output = 'test.mp3';
var named_pipe = 'pipe';
var fifo = spawn('mkfifo', [ named_pipe ]);
fifo.on('exit', function() {
var mplayer = spawn('mplayer', [ input, '-ao', 'pcm:file=' + named_pipe ]);
var cat = spawn('cat', [ named_pipe ]);
var ffmpeg = spawn('ffmpeg', [ '-y', '-i', '-', output ]);
cat.stdout.on('data', function(data) {
ffmpeg.stdin.write(data);
});
cat.on('exit', function(){
ffmpeg.stdin.end();
});
ffmpeg.on('exit', function() {
spawn('rm', [ named_pipe ]);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment