title: Pipe output of ffmpeg using nodejs stdout
body: <p>I am not being able to pipe the output of the ffmpeg over a stdout. </p>
  
  <p>Following are the block of code what I coded so far.</p>
  
  <pre><code>    var http = require('http')
      , fs = require('fs') 
      var child_process = require("child_process")
  
      http.createServer(function (req, res) {
      console.log("Request:", dump_req(req) , "\n")
  
      // path of the 
      var path = 'test-mp4.mp4'  //test-mp4-long.mp4
      , stat = fs.statSync(path)
      , total = stat.size
  
  
      var range = req.headers.range
      , parts = range.replace(/bytes=/, "").split("-")
      , partialstart = parts[0]
      , partialend = parts[1]
      , start = parseInt(partialstart, 10)
      , end = partialend ? parseInt(partialend, 10) : total-1
      , chunksize = (end-start)+1
  
  
      console.log('RANGE: ' + start + ' - ' + end + ' = ' + chunksize +  "\n")
  
  
      var ffmpeg = child_process.spawn("ffmpeg",[
              "-i", path,             // path
              "-b:v" , "64k",         // bitrate to 64k
              "-bufsize", "64k", 
              "-"                     // Output to STDOUT
          ]);
  
  
      //set header
      res.writeHead(206
      , { 'Content-Range': 'bytes ' + start + '-' + end + '/' + total
      , 'Accept-Ranges': 'bytes', 'Content-Length': chunksize
      , 'Content-Type': 'video/mp4'
      })
  
      stdout[ params[1] ] = ffmpeg.stdout
  
      // Pipe the video output to the client response
      ffmpeg.stdout.pipe(res);
  
      console.log("Response", dump_res(res), "\n")
      }).listen(1337)
  </code></pre>
  
  <p>When i replaced the ffmpeg stuffs from above code, all works fine. Following is the part of the code when i replace the ffmpeg stuffs.</p>
  
  <pre><code> var file = fs.createReadStream(path, {start: start, end: end})
  </code></pre>
  
  <p>And piping like:</p>
  
  <pre><code>file.pipe(res)
  </code></pre>
  
  <p>What wrong I am running? </p>
  
  <p><strong>Edit:</strong>
  The ffmpeg command works fine. I have tested this through the command line and generating proper output.</p>