Understanding the MPEG-4 moov atom: Pseudo-Streaming in Mp4

Progressive Download

The progressive download method downloads and caches video on the viewer’s device. A short period of time is required to buffer and cache the beginning of the media file before it starts playing. Your player can calculate an appropriate buffer time based on the rate the data is being received and the total length of the video. Once the video has been cached, subsequent viewing does not require any buffering. Generally you would use a content delivery network (CDN) using the standard HTTP protocol to deliver these videos. While this method is efficient when used through CDN for delivery, there is yet another detail to be considered to make the whole playback experience smooth for your end user, called pseudo-streaming which is still progressive download but with a twist.

Pseudo-Streaming

So, what is pseudo-streaming? It is simply a video that can play while it’s being downloaded i.e. it can start playing even before its completely downloaded.

The moov atom

In an MPEG-4-compliant container, every movie contains a moov atom. Normally, a movie atom contains a movie header atom (an mvhd atom) that defines the timescale and duration information for the entire movie, as well as its display characteristics. The movie atom also contains one track atom (a trak atom) for each track in the movie. Each track atom contains one or more media atoms (an mdia atom) along with other atoms that define other track and movie characteristics.

Figure 1: moov atom Structure

Importance of moov atom Location

As explained earlier, positioning the moov atom at the beginning of the file structure expedites the playback experience and access to the data payload for decoding and presentation by the player. In case of progressive download, the moov atom data must be received before playback can begin.

Finding moov atom Location and Placing it Properly

Now let’s talk about a scenario where you already have video archive and want to check if it is ‘fit’ to be streamed over HTTP as progressive download.

Figure 2: Output of mediainfo based command
  • Re-encoding takes much longer than using a utility to move the Moov Atom so here’s how we will do it:
  1. Create new video files with correct config:
  • New files will have ‘_NEW’ in the name
  • If you have other files in the same folder, use the -E in grep and add more extension in search that you want to exclude from reverse-search e.g.: ls | grep -vE ‘_NEW|.jpg|.png|other name/ext in your folder’

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sanjeev Pandey

Sanjeev Pandey

Co-Founder of <indvideotech> community for Video Engineers in India. Solution Architect, Full-Stack Developer, Ad Insertion Evangelist, and Think Tank.