12

As I understand, ffmpeg by default places all meta info at the end of the file when generating mp4s. Source: http://www.stoimen.com/blog/2010/11/12/how-to-make-mp4-progressive-with-qt-faststart/

What I need to do is create the video, one frame at a time and then stream it. This is impossible if the header info is at the 'end' of the file. But is it possible to move this to the beginning or otherwise work around this? I would definitely prefer to not have to switch to another library and use it instead.. we're already over-budget on this project.

Edit: Has to be done within code as I am converting one frame at a time and would like to then instantly stream it instead of command like.

mczarnek
  • 307
  • 1
  • 3
  • 13

1 Answers1

14

ffmpeg supports -movflags faststart on command line. See http://salman-w.blogspot.co.il/2013/08/fast-start-enabled-videos-with-ffmpeg.html for more info.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • For my purposes I have have to do it within code as I am converting one frame at a time and would like to then instantly stream it instead of converting via command line then streaming.. however I appreciate this, I will do some more research to see if I can to it with code. Thank you! – mczarnek Feb 10 '14 at 20:27
  • 5
    I don't think this can work. `faststart` involves a second pass moving the index (moov atom) to the beginning of the file. This operation can take a while, and will not work in various situations such as fragmented output, thus it is not enabled by default. Why not use `mpegts`? – Alex Cohn Feb 10 '14 at 21:25
  • 1
    @mczarnek Since you are streaming during the encoding process, this isn't possible as all the information needed for faststart doesn't exist until encoding is finished. – Brad Feb 10 '14 at 21:27
  • Not using mpegts because HTML5 video doesn't support it and one of the requirements of this project is that we can stream the video into an HTML video player. Anyone know why mp4 needs to go through the entire file before generating their header? Is this only if it's ffmpeg generated? Or mp4s simply can't be streamed live? – mczarnek Feb 10 '14 at 22:09
  • Not a long while ago, there was an eyeopening discussion here: _[Live Streaming Through mp4](http://stackoverflow.com/questions/13010530/live-streaming-through-mp4)_. AFAIK, the ** – Alex Cohn Feb 11 '14 at 09:38