When an MP4 is encoded normally, the metadata sits at the end of the file. A web player must download the entire file before it can start playing, which is slow for long videos. The `-movflags +faststart` flag moves the metadata to the front of the file during a second pass, so the player can start streaming immediately.

The command

ffmpeg -i in.mp4 -movflags +faststart -c:v libx264 -crf 20 out.mp4

What it does

The command encodes the video with libx264, then runs a second pass that moves the moov atom to the front of the file. The output is a normal MP4 that plays in any web player with progressive streaming. The second pass is fast (typically milliseconds) and adds no quality cost. For very large files, the pass may take a few seconds, but it is always worth it for web delivery.

Requirements

An MP4 output. The flag is a no-op for other containers. The encode is a two-pass, so the cost is the same as a single pass plus a fast file rewrite. No special hardware, no special build.

Things to avoid

  • Using `-movflags +faststart` on a file that is already encoded. The flag works during the encode, not after; for an existing file, use `qt-faststart` (an external tool) or re-encode.
  • Forgetting that the flag is a one-time cost. The moov atom is moved once, and the resulting file plays in any player that supports the codec.
  • Combining the flag with stream copy. Stream copy produces a file with the moov at the end; for a faststart file, re-encode with the flag.
  • Expecting the flag to work on non-MP4 containers. The moov atom is an MP4 concept; MKV, AVI, and WebM have their own streaming-friendly headers.