title: Streaming without Content-Length in response
body: <p>I'm using Node.js, Express (and connect), and fluent-ffmpeg.</p>
  
  <p>We want to stream audio files that are stored on Amazon S3 through http.</p>
  
  <p>We have all working, except that we would like to add a feature, the on-the-fly conversion of the stream through ffmpeg.</p>
  
  <p>This is working well, the problem is that some browsers checks in advance before actually getting the file.</p>
  
  <p>Incoming requests containing the Range header, for which we reply with a 206 with all the info from S3, have a fundamental problem: we need to know in advance the content-length of the file.</p>
  
  <p>We don't know that since it is going through ffmpeg.</p>
  
  <p>One solution might be to write out the resulting content-length directly on S3 when storing the file (in a special header), but this means we have to go through the pain of having queues to encode after upload just to know the size for future requests.
  It also means that if we change compressor or preset we have to go through all this over again, so it is not a viable solution.</p>
  
  <p>We also noticed big differencies in the way Chrome and Safari request the audio tag src, but this may be discussion for another topic.</p>
  
  <p>Fact is that without a proper content-length header in response everything seems to break or browsers goes in an infinite loop or restart the stream at pleasure.</p>
  
  <p>Ideas?</p>