Move metadata to the beginning of the file

useful tips

// what it does

Losslessly rewrites the container with -c copy (no re-encode) while -movflags +faststart relocates the moov atom — the index and metadata — from the end of the MP4 to the front. Encoders normally can only finalize the moov after all frames are written, so it lands at the tail; moving it to the head lets browsers and players start playback before the whole file downloads. This is the standard fix for MP4s served over HTTP that stall until fully buffered.

// shell

$ ffmpeg -i input.mp4 -c copy -movflags +faststart output.mp4

// gotcha

faststart needs a second pass that rewrites the entire file after the first write, so the output must be seekable — you can't pipe it to stdout or a non-seekable target, and it only applies to MP4/MOV, not MKV or WebM.