file-formatquicktimempeg

How to parse this Apple-specific MPEG file header?


I have an MPEG file which starts like this:

   0:  00 0f 6d 79 5f 66 69 6c  65 6e 61 6d 65 2e 6d 70  ..my_filename.mp
  10:  67 00 04 fc 00 00 f0 00  b2 10 39 a8 b2 10 39 ad  g.........9...9.
  20:  0f 6d 79 5f 66 69 6c 65  6e 61 6d 65 2e 6d 70 67  .my_filename.mpg
  30:  03 92 3b 40 00 00 00 00  03 7a b5 7c 03 7a d7 d0  ..;@.....z.|.z..
  40:  00 4d 6f 6f 56 54 56 4f  44 01 00 01 2a 00 80 00  .MooVTVOD...*...
  50:  00 00 00 00 36 b2 83 00  00 04 fc b2 10 39 a8 b2  ....6........9..
  60:  10 39 ad 00 00 00 00 00  00 00 00 00 00 00 00 00  .9..............
  70:  00 00 00 00 00 00 00 00  00 00 81 81 35 d3 00 00  ............5...
  80:  00 36 b2 83 6d 64 61 74  00 00 01 ba 21 00 01 00  .6..mdat....!...
  90:  05 80 2b 81 00 00 01 bb  00 0c 80 2f d9 04 e1 ff  ..+......../....
  a0:  c0 c0 20 e0 e0 2e 00 00  01 c0 07 ea ff ff ff ff  .. .............

What is the file format of the beginning of the file (first 0x80 bytes), and how do I parse it?

I've run a Google search on MooVTVOD, it looks like something related to QuickTime and iTunes.

What I understand already:


Solution

  • The file format of the first 0x80 bytes in the question is MacBinary II.

    Based on the file format description https://github.com/mietek/theunarchiver/wiki/MacBinarySpecs , it's not MacBinary I, because MacBinary II has data[0x7a] == '\x81' and data[0x7b] == '\x81' (and MacBinary I has data[0x7a] == '\x00', and MacBinary III has data[0x7a] == '\x82'); and it's also not MacBinary III, because that one has data[0x66 : 0x6a] == 'mBIN'.

    The CRC value data[0x7c : 0x7e] is incorrect because the filename was modified before posting to StackOverflow. FYI The CRC algorithm used is CRC16/XMODEM (on https://crccalc.com/), also implemented as CalcCRC in MacBinary.c.

    The data[0x41 : 0x45] == 'MooV' is the file type code. According to the Excel spreadsheet downloadable from TCDB, it means QuickTime movie (video and maybe audio).

    The data[0x45 : 0x49] == 'TVOD' is the file creator code. TCDB and this database indicate that it means QuickTime Player.

    More info and links about MacBinary: http://fileformats.archiveteam.org/wiki/MacBinary

    Please note that all these headers are unnecessary to play the video: by removing the first 0x88 bytes we get an MPEG-PS video file, which many video players can play (not only QuickTime Player, and not only players running on macOS).