title: nginx-rtmp + ffmpeg move mp4's moov to head on the fly
body: <p>I have the following use case:</p>
  
  <p>1) Alice publish stream to the nginx-rtmp server</p>
  
  <p>2) The server convert the stream to mp4 (default is flv if I understand correctly, and a codec transformation is needed)</p>
  
  <p>3) Bob should be able to do range request to that mp4 file while Alice is still publishing</p>
  
  <p>However it seems ffmpeg command for converting a flv to mp4 can only be done when the mp4 file is fully generated, and then ffmpeg will do second pass and move "moov" to its new file's head</p>
  
  <p>Our use case is to allow Bob use range request to retrive the mp4 file while Alice is still publishing (i.e. watch Alice's video as soon as possible) from time 0 (i.e. from the second Alice started publishing). Thus with mp4's moov at its head, it's simple to do range requests and implement the functionality. Raw RTMP doesn't seem to solve our problem, since we can't let Bob watch from time 0 of Alice's recording. </p>
  
  <p>The question is:
  1) Is it possible to do it while the flv is not fully generated yet?
  2) Any other idea how shall we use nginx-rtmp/ffmpeg to achieve the functionality we desire?</p>
  
  <p>Thanks a bunch</p>