Rewraps a QuickTime/MP4 file without re-encoding and moves the index (the moov atom) to the start of the file, so browsers can begin playback before the whole file has downloaded. Fast and lossless: only the container changes, every audio and video packet is copied as-is.
Also in notes/ffmpeg-filters.txt: the same remux without +faststart, in a *.mov loop. Keep +faststart for anything played on the web.
The command
ffmpeg -i input.mov \
-c copy \
-movflags +faststart \
output.mp4 What each part does
-c copy copy every stream, no re-encode
-movflags +faststart write the moov atom at the start of the file When to use it
This is for when a video already uses codecs a browser can play, but sits in a .mov, or in an MP4 that won't start playing until it has fully downloaded. Nothing is re-encoded, so it runs about as fast as the file can be copied and quality is unchanged. The header explains each flag.
It can't fix the codecs themselves. A ProRes or other editing-format .mov becomes an MP4 that a browser still won't play. For those, re-encode with a script such as web-mp4-baseline-keep-size.sh instead.
To adapt it, change input.mov and output.mp4. An existing MP4 works as input too. Keep +faststart for anything played on the web.
If the output looks wrong:
- ffmpeg stops with an error about a codec or tag: one of the streams can't go into an MP4 container as-is, so it needs a re-encode.
- The file plays locally but not in the browser: the source codecs aren't web-friendly.
- An extra audio track or subtitle stream is missing: by default ffmpeg keeps one stream of each type, not every stream.
Notes
- Source
- ffmpeg-utilities/faststart.sh (same command in vector.sh, vector 2.sh, vector 3.sh, vector 4.sh)
- Changed
- -c:v copy -c:a copy → -c copy; faststart → +faststart