title: HTML5 <audio>/<video> and live transcoding with FFMPEG
body: <p>So from my web server, I would like to use FFMPEG to transcode a media file for use with an HTML <code>&lt;audio&gt;</code> or <code>&lt;video&gt;</code> tag. Easy enough right?</p>
  
  <p>The conversion would need to take place in real-time, when an HTTP client requested the converted file. Ideally the file would be streamed back to the HTTP client as it is being transcoded (and not afterwards at the end, since that would potentially take a while before any data starts being sent back).</p>
  
  <p>This would be fine, except that in today's browsers, an HTML5 audio or video tag requests the media file in multiple HTTP requests with the <code>Range</code> header. <a href="https://stackoverflow.com/questions/1995589/html5-audio-safari-live-broadcast-vs-not">See this question for details</a>. </p>
  
  <p>In that question linked above, you can see that Safari requests weird chunks of the file, including the ending few bytes. This poses a problem in that the web server WOULD have to wait for the conversion to finish, in order to deliver the final bytes of the file to conform to the <code>Range</code> request.</p>
  
  <p>So my question is, is my train of thought right? Is there a better way to deliver transcoding content to an <code>&lt;audio&gt;</code> or <code>&lt;video&gt;</code> tag that wouldn't involve waiting for the entire conversion to finish? Thanks in advance!</p>