Drupal 7, MediaFront, MPEG-4 moov atoms, and buffering
In this article, I'll address why some MPEG files buffer/load completely before playing and then give you several solutions to resolve this issue. For some background, it's well documented that MPEG-4 files could buffer completely before playing from a website. If you have a very small video, this might not be an issue. With video times of 15, 30, or even 60 mins+, it can be a real issue for many site builders. Even my 4 min videos were driving me nuts . . .
After a bit of research, I found out this issue is related to moov (movie) atoms which are pieces of metadata stored within the video file. When these atoms are at the end of the file, the entire video file must load before playing. The metadata contains all sorts of information about the file. If the player doesn't get the metadata when the file first loads, it has to wait until it sees the data before it can start to play. To understand all the low-level details, read this excellent article, Understanding the MPEG-4 movie atom.
The easiest solution is to determine if your encoding software has an option to store the moov atoms at the beginning of the file. For me, I was converting WMV files to MPEG-4 and using Handbrake. During my conversions, I did not use the
Web optimized option. But, when I checked this option, the moov atoms were correctly located at the beginning of the file. I'll show you how to determine where your moov atoms are located in a moment.
That's great but what if you've converted 100's of video files to MPEG-4 already?
How do you like your parsley?
One thing I love about Open Source is how we come up with our names... Just know that AtomicParsley will soon become your best friend when you need to check where your moov atoms are located. And, I know that checking my moov on Friday night is where the action is at!
To check the location of your moov atoms,
# In a shell or terminal. $ AtomicParsley
will display all atoms in your video file. You want to ensure your
Atom moov lines are ABOVE your
Atom mdat line.
Atom mdat represents the video data. The best way to see this in action to view the AtomicParsley home page. Look at the AtomicParsley output.
So, now you're like me . . . your
Atom moov lines are at the end of the AtomicParsley output, what's next?
A French lesson from Ecole Nationale Supérieure des Télécommunications
You'll need to download/install GPAC to gain access to MP4Box. For Ubuntu, a simple
# In a shell or terminal. AtomicParsley
works just fine. On .rpm distributions, download the latest rpmfusion-free-release-stable.
# In a shell or terminal. rpm -Uvh rpmfusion-free-release-stable.rpm yum install gpac
Lets move some moovs
There are two MP4Box options when preparing your file for web-based video streaming. Both of these commands will overwrite your original file. Make a backup! Also, you can use the
-new option to create a new file once your conversion is complete. And, you can batch process so regardless of how many files you have, it's a simple process.
# In a shell or terminal. MP4Box -inter
-inter option is used to interleave media data in chunks of the desired duration and places the moov atoms at the beginning of the file. The
-isma option is used to convert the video file to ISMA 1.0 specification. I tried both options above and both moved the metadata to the beginning of the file. During the conversion process, I noticed that the
-isma option also performed the same processing as the
-inter option. So, I decided to use the
-isma option for my needs. If in doubt, read the MP4Box documentation and see which option makes sense for you.
Once you're done, MEPG videos streamed from your website will play in a few seconds after loading!
Comments, questions, errors, typos? Do you use something different? Let me know!