Log in

View Full Version : [x /H264]: moov atom at the front of the file (Fast Start)


NyaR
5th July 2015, 10:17
Hi all,

I am working with Avisynth, megui, and h264 to create the ultimate quality presets for YouTube.

YouTube's suggestion (https://support.google.com/youtube/answer/1722171)is to put
moov atom at the front of the file (Fast Start)

I've looked around but cannot find a method to achieve this in h264/x264.

Please assist if there is a command line I can use in h264 / x264 to put moove atom to the front of file.

Thank you.

sneaker_ger
5th July 2015, 10:26
That's usually done at the muxing stage. Did you confirm that MeGUI isn't doing this already?

http://forum.doom9.org/showthread.php?t=168601

LoRd_MuldeR
5th July 2015, 15:10
You can think of the moov atom is something like the global "index table" of the MP4 file. It can be located at the beginning of the file (before mdat atom) or at the end of the file (after mdat atom).

For local file playback it doesn't matter much, but for streaming (progressive download) you want to have the moov atom at the beginning of the file - for obvious reasons.

However, x264 will append the frames to the MP4 file as they are encoded. And, since the exact size of each frame cannot be known before they have actually been encoded, the index (moov atom) will be written last, at the end of the file.

So you cannot make x264 output an MP4 file with moov atom at the beginning. At least not directly. But you can achieve this easily with a tool like MP4Box or AtomicParsley!

mp4box.exe -add c:\Temp\input.mp4 c:\Temp\output.mp4

NyaR
5th July 2015, 22:28
Thanks for helping me out sneaker_ger and LoRd_MuldeR.

As it stands I am using Sony Vegas to output a .avi with Debugmode frameserver. Then I grab that .avi Megui and create an AVS for it and put the same .avi as the audio input. Then MeGUI muxes the two together into an mp4 - and it already puts moov atom to front!

I never attempted to put moov atom to front so I figured it wasn't. By using mp4box.exe -info I was able to find that it is.

I will post back here in a month or two with a guide for the ultimate presets once I am certain they are complete :D

benwaggoner
9th July 2015, 16:18
For local file playback it doesn't matter much, but for streaming (progressive download) you want to have the moov atom at the beginning of the file - for obvious reasons.
...unless the file is on a server that supports byterange requests, in which case many players will still work correctly.

Which is dangerous, because the file might look like it's fine with some server/player combinations, and work horribly with others. Making Fast Start all the more important, since just having the file work in progressive download doesn't mean it'll always work.

This was such a huge problem 5-20 years ago. Fortunately we now have adaptive streaming with fragmented mp4 and moof headers for commercial content delivery.

Z2697
17th February 2025, 06:13
were you able to do it?

I saw your another post about rescuing an unfinalized mp4, this topic is completely different.

"Fast start" usually means to move the moov atom from file end to front, after the file had finalized.
If this is what you want to do, you can easily achieve it by setting "-movflags +faststart" in FFmpeg.

MP4 is kinda "hard to work with", to be honest.