Exporting web-optimized MP4 files
If you upload MP4 files that are already suitable for online playback, MediaLab can use them as they are, and you don't need to wait for transcoding. One requirement is easy to miss: the file must be web-optimized, also called fast start. This article explains what that means and how to set it up in your encoder.
What is the moov atom?
An MP4 file is made up of blocks called "atoms". The moov atom holds the file's index: the duration, the tracks, and where each video and audio frame is stored in the file.
Many encoders write the moov atom at the end of the file, because the index is only complete once encoding has finished. A video player then has to download the whole file before playback can start. If the moov atom is at the start of the file, the video can start playing straight away while the rest is still loading.
Moving the moov atom does not change the video or audio. Only the order of the blocks inside the file changes, so there is no loss in quality.
What happens if the moov atom is at the end?
If your MP4 meets all other requirements, MediaLab still can't use it for playback as is. Instead, it creates a second copy with the moov atom moved to the start. This means:
- extra processing time before the video is playable
- an extra copy of the video in your storage
If the file is stored on external storage, MediaLab has to fully transcode it instead.
If you export with fast start enabled, no extra step is needed.
How to enable fast start
The setting has a different name in different encoders. Look for options such as Fast start, Web optimized, Optimize for streaming or Progressive download.
FFmpeg
Add -movflags +faststart to your MP4 output:
ffmpeg -i input.mov -c:v libx264 -b:v 5M -c:a aac -ac 2 -movflags +faststart output.mp4
This also applies to custom encoders and tools built on FFmpeg or libav. Set the movflags option to +faststart on the MP4 output.
HandBrake
Under Summary, enable Web Optimized.
Fixing an existing file
If your encoder has no fast start option, you can move the moov atom after exporting. This does not re-encode the video, so it only takes a few seconds:
ffmpeg -i export.mp4 -c copy -movflags +faststart export_faststart.mp4
Tools such as MP4Box and qt-faststart can do the same.
Checking your file
You can check whether a file is web-optimized with MediaInfo:
mediainfo --Full export.mp4
In the General section, look for:
IsStreamable : Yes
If it says No, the moov atom is at the end of the file.
Other requirements for skipping transcoding
Fast start is only one of the requirements. To be used for playback as is, a video must also:
- be an
.mp4file - use the H.264 video codec
- have a bitrate no higher than the bitrate set for your account or folder (with a small margin)
- have a resolution no higher than the configured playback format
- not need a watermark, timecode overlay, rotation or deinterlacing
If you upload at a higher bitrate than your account's default, also raise the default bitrate. Otherwise MediaLab transcodes the video down to the lower bitrate. See Choosing the right bitrate for your video and Uploading a video without transcoding for more information.