Tools to fix MP4 videos so players can start playback instantly (without downloading the whole file)

There're tons of these for the various platforms.

  • AtomicParsley: this helps you print out the atom tree so you can check whether the moov atom is in the right place.
    Eg.
    AtomicParsley sample.mp4 -T
  • qtfaststart: can list the top-level atoms in a MOV or MP4 file.
  • MP4Muxer: another tool that can print the atom structure for you.
  • MP4Box: simple and easy way to solve the problem.
    Eg.
    MP4Box -add fixed.mp4 -isma sample.mp4
  • MP4 FastStart: a Windows tool to move the moov atom.
  • qt-faststart: a tool shipped with ffmpeg that moves the moov atom to the start of the file
  • moovrelocator: a PHP solution for the same problem.
Since AtomicParsley and MP4Box are both open-source and available for most platforms, you can easily automatize the detection and fix of the moov placement problem. Or you can just run MP4Box without even bothering where the moov atom is. Smile

To find all MP4 files with bad moov atom placement, you can use a shell script like this:
find '/path/to/videos' -iname '*.mp4' -exec sh -c 'AtomicParsley "{}" -T | awk "BEGIN {mdat=0; moov=0} /^Atom mdat / {if (mdat == 0) mdat = NR} /^Atom moov / {if (moov == 0) moov = NR} END {exit (moov > mdat ? 0 : 1)}"' \; -print

I've attached a shell script that finds and fixes MP4 files in a directory tree. You can run it periodically via crontab. Comes handy if you've incoming MP4 files (eg. via FTP upload) that you've to stream.

AttachmentSize
fix_mp4_moov.sh1.65 KB
Syndicate content