Using FFmpeg to locate moov atom

20

3

I have a library of videos, all of which should have been adjusted for web-streaming by putting the moov atom ahead of the rest of the video. This allows playback to begin before the client has completely downloaded the video.

Is there a reliable way to check if a certain video has been adjusted by locating how many bytes in the moov atom occurs? This is for debugging purposes only.

Jamie Taylor

Posted 2013-03-01T15:00:30.680

Reputation: 1 031

4Just for reference for others interested in placing the moov atom in the beginning to facilitate playback see the -movflags faststart option or the qt-faststart tool in ffmpeg. – llogan – 2013-03-01T18:59:26.623

Answers

22

FFmpeg won't show you this information, really.

You could use AtomicParsley to parse the file, e.g.:

AtomicParsley input.mp4 -T 

This will show you the location of the atoms in a tree. If the moov atom is at the beginning of the file, it'll have to come right after the ftyp atom, so you could try parsing the output, e.g. in Bash, only printing the second line and checking whether it contains moov:

AtomicParsley input.mp4 -T | sed -n 2p | grep -q "moov" && echo "yup" || echo "nope"

slhck

Posted 2013-03-01T15:00:30.680

Reputation: 182 472

Haha, well… glad to help :) – slhck – 2013-03-04T09:29:56.177

Note, this will not work on YouTube DASH files. – Steven Penny – 2014-04-28T07:43:47.040

1@StevenPenny Right, DASH segments do not contain the entire Atom tree, because they're only segments, not complete ISO Base Media files. – slhck – 2014-04-28T08:29:58.773

12

Using this qtfaststart (not the same as ffmpeg's qt-faststart), qtfaststart -l input.mp4 will display the order of the top-level atoms.

$ qtfaststart -l bad.mp4
ftyp (32 bytes)
free (8 bytes)
mdat (559619 bytes)
moov (52916 bytes)
$ qtfaststart -l good.mp4
ftyp (32 bytes)
moov (52916 bytes)
mdat (559619 bytes)
$

mark4o

Posted 2013-03-01T15:00:30.680

Reputation: 4 729

3If you have pip installed you can install qtfaststart with pip install qtfaststart – qff – 2016-04-19T11:48:21.717

You can also install with Homebrew: brew install qtfaststart – Brandon Durham – 2018-12-28T18:07:44.157

-1

You can do this with FFprobe:

ffprobe -v trace infile.mp4

Or with Bento4:

$ mp4info infile.m4a
File:
  major brand:      isom
  minor version:    200
  compatible brand: isom
  compatible brand: iso2
  compatible brand: mp41
  fast start:       no

$ mp4info outfile.m4a
File:
  major brand:      isom
  minor version:    200
  compatible brand: isom
  compatible brand: iso2
  compatible brand: mp41
  fast start:       yes

Steven Penny

Posted 2013-03-01T15:00:30.680

Reputation: 7 294