31

Is it possible to run ffmpeg from the command line which will either place the 'moov atom' metadata in the beginning of the MP4 file or run the qt-faststart as a post processing operation in ffmpeg so the generated file is stream-able through the internet?

I can of course run it as a separate command, but would prefer it to be something

  • as an option within ffmpeg, or
  • as part of a post conversion, command line option when converting the video files via ffmpeg

Edit 1

http://ffmpeg.org/ffmpeg.html#mov

MOV / MP4 muxer

The muxer options are:

‘-moov_size bytes’

Reserves space for the moov atom at the beginning of the file instead of 
placing the moov atom at the end. If the space reserved is insufficient, 
muxing will fail.
siliconpi
  • 7,593
  • 15
  • 64
  • 105

3 Answers3

67

Seems like faststart support has been included in ffmpeg. FFmpeg Formats Documentation:

-movflags faststart

Run a second pass moving the moov atom on top 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.

Salman A
  • 229,425
  • 77
  • 398
  • 489
  • 1
    This worked for me. It does a second pass and then the moov atom is moved to beginning. Cheers! – arrayown Oct 01 '13 at 13:27
  • This worked for me only when I had the `-codec:v libx264` arguments. To support this, I had to configure ffmpeg with the `--enable-gpl --enable-libx264` options. – Zugwalt Oct 21 '13 at 03:56
  • Any idea in which version this was added? – DanMan Nov 29 '13 at 09:49
  • 1
    android's video element can start playing video via http streaming even if the moov atom is at the end. how is that possible ? – Sagar Pilkhwal Dec 08 '15 at 06:33
  • 2
    @SagarPilkhwal It probably uses the HTTP Range header to request bytes from the end of the file. The web server must support it. Same mechanism as download resuming. – Aleksandr Dubinsky Aug 22 '16 at 17:27
  • 2
    command: ffmpeg -i input.mp4 -vcodec copy -acodec copy -movflags faststart output.mp4 – Joey May 03 '18 at 07:43
9

Ended up setting up and running qt-faststart after ffmpeg conversion process.

siliconpi
  • 7,593
  • 15
  • 64
  • 105
  • 21
    This i more aptly a comment rather an answer. @stharward response qualifies more as an answer. – Samuel Sep 07 '12 at 08:48
1

ffmpeg has a option for smooth streaming

-movflags isml+frag_keyframe

and it's also useful for avoid corrupt videos when power loss during recording