25

I want to add -movflags +faststart to an mp4 file. Basically that is all I want to do, nothing else should be changed. I am using ffmpeg.

What's the fastest way to do this? Do I have to re-encode the whole video? Or is there a better/easier way?

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Jonas Kaufmann
  • 1,797
  • 3
  • 22
  • 43

1 Answers1

38

As simple as:

ffmpeg -i in.mp4 -c copy -map 0 -movflags +faststart out.mp4

Or if you can compile FFmpeg from source, make the tool qt-faststart in the tools/ directory and run it:

qt-faststart in.mp4 out.mp4

You can also use mp4box, which lets you move the MOOV atom to the start via this command:

mp4box -inter 0 in.mp4 -out out.mp4

Or if you want to fully optimize for streaming by also interleaving the audio/video data so that the file can be easily streamed in realtime:

mp4box -inter 500 in.mp4 -out out.mp4
Mitch McMabers
  • 3,634
  • 28
  • 27
Gyan
  • 85,394
  • 9
  • 169
  • 201
  • You may want to add `-map_metadata 0` too in order to preserve any metadata – Mikael Finstad May 04 '20 at 10:05
  • Is there any way to "fully optimize" with ffmpeg instead of mp4box? I would be doing a transcode with ffmpeg, so it would be nice not to run a separate command. – Dmitry Minkovsky May 14 '20 at 16:18
  • @Gyan I'm sorry, I meant is there also a way to **interleave** with ffmpeg like with mp4box. Or, are you saying `faststart` will interleave the results? Not finding anything on Google – Dmitry Minkovsky May 14 '20 at 16:41
  • 1
    The MP4 muxer in ffmpeg does not support custom interleaving delta. faststart only relates to where the metadata is placed. – Gyan May 14 '20 at 17:53
  • @Gyan just seeing your reply now. Thanks a lot. – Dmitry Minkovsky Nov 06 '20 at 02:41
  • 1
    The ffmpeg command above (with either "+faststart" or just "faststart") gives me "moov atom not found" (the same error I'm trying to fix) I'm running on an .m4v file. – Jonathan Hartley Nov 16 '21 at 16:24
  • Is there a way to not do it under a new file and add it to the same header of the main file without reading the entire data of the file, so that we can reach the goal faster? – Nabi K.A.Z. Aug 27 '22 at 12:36