Issue parsing keywords from recent iPhone .mp4 movie

Started by mceachen, February 06, 2021, 01:37:42 PM

Previous topic - Next topic

mceachen

It looks like the QuickTime.pm `kywd` parser isn't handling .mp4 files produced from recent iOS devices properly.

1) Your system type (Windows XP, Linux, Mac, etc)

(reproduced on both macOS and Linux: this isn't a platform-specific issue)

2) The ExifTool version you are using (the output of the "exiftool -ver" command).

v12.17

3) The specific command line you are using (or a sample script if having problems with the API).

exiftool -j -Keywords movie.mp4

4) The console output from the command.

$ ./exiftool -Keywords -j ~/Desktop/err-kywd.MP4
[{
  "SourceFile": "/home/mrm/Desktop/err-kywd.MP4",
  "Keywords": "<err>"
}]

$ ./exiftool -v4 -Keywords -j ~/Desktop/err-kywd.MP4
  ExifToolVersion = 12.17
  FileName = err-kywd.MP4
  Directory = /home/mrm/Desktop
  FileSize = 50488533
  FileModifyDate = 1612636058
  FileAccessDate = 1612636076
  FileInodeChangeDate = 1612636075
  FilePermissions = 33204
  FileType = MP4
  FileTypeExtension = MP4
  MIMEType = video/mp4
  FileType (SubDirectory) -->
  - Tag 'ftyp' (20 bytes):
      0008: 6d 70 34 32 00 00 00 01 69 73 6f 6d 6d 70 34 31 [mp42....isommp41]
      0018: 6d 70 34 32                                     [mp42]
  + [BinaryData directory, 20 bytes]
  | MajorBrand = mp42
  | - Tag 0x0000 (4 bytes, undef[4]):
  |     0008: 6d 70 34 32                                     [mp42]
  | MinorVersion = .
  | - Tag 0x0001 (4 bytes, undef[4]):
  |     000c: 00 00 00 01                                     [....]
  | CompatibleBrands = isommp41mp42
  | - Tag 0x0002 (12 bytes, undef[12]):
  |     0010: 69 73 6f 6d 6d 70 34 31 6d 70 34 32             [isommp41mp42]
  Movie (SubDirectory) -->
  - Tag 'moov' (124046 bytes):
      0024: 00 00 00 6c 6d 76 68 64 00 00 00 00 da fc 91 56 [...lmvhd.......V]
      0034: da fc 93 53 00 00 75 30 00 4a c4 37 00 01 00 00 [...S..u0.J.7....]
      0044: 01 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 [................]
      0054: 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 [................]
      0064: 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 [............@...]
      0074: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [................]
      0084: 00 00 00 00 00 00 00 00 00 00 00 03 00 00 8d 1e [................]
      0094: 74 72 61 6b 00 00 00 5c 74 6b 68 64 00 00 00 01 [trak...\tkhd....]
      00a4: da fc 91 56 da fc 93 53 00 00 00 01 00 00 00 00 [...V...S........]
      00b4: 00 4a c4 37 00 00 00 00 00 00 00 00 00 00 00 00 [.J.7............]
      00c4: 01 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 [................]
      00d4: 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 [................]
      00e4: 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 [....@...........]
      00f4: 00 00 00 24 65 64 74 73 00 00 00 1c 65 6c 73 74 [...$edts....elst]
      0104: 00 00 00 00 00 00 00 01 00 4a c4 37 00 00 08 40 [.........J.7...@]
      0114: 00 01 00 00 00 00 8c 96 6d 64 69 61 00 00 00 20 [........mdia... ]
      0124: 6d 64 68 64 00 00 00 00 da fc 91 56 da fc 93 53 [mdhd.......V...S]
      0134: 00 00 bb 80 00 77 ac 00 15 c7 00 00 00 00 00 31 [.....w.........1]
      0144: 68 64 6c 72 00 00 00 00 00 00 00 00 73 6f 75 6e [hdlr........soun]
      0154: 00 00 00 00 00 00 00 00 00 00 00 00 43 6f 72 65 [............Core]
      0164: 20 4d 65 64 69 61 20 41 75 64 69 6f 00 00 00 8c [ Media Audio....]
      0174: 3d 6d 69 6e 66 00 00 00 10 73 6d 68 64 00 00 00 [=minf....smhd...]
      0184: 00 00 00 00 00 00 00 00 24 64 69 6e 66 00 00 00 [........$dinf...]
      0194: 1c 64 72 65 66 00 00 00 00 00 00 00 01 00 00 00 [.dref...........]
      01a4: 0c 75 72 6c 20 00 00 00 01 00 00 8c 01 73 74 62 [.url ........stb]
      01b4: 6c 00 00 00 67 73 74 73 64 00 00 00 00 00 00 00 [l...gstsd.......]
      01c4: 01 00 00 00 57 6d 70 34 61 00 00 00 00 00 00 00 [....Wmp4a.......]
      01d4: 01 00 00 00 00 00 00 00 00 00 02 00 10 00 00 00 [................]
      01e4: 00 bb 80 00 00 00 00 00 33 65 73 64 73 00 00 00 [........3esds...]
      01f4: 00 03 80 80 80 22 00 00 00 04 80 80 80 14 40 14 [....."........@.]
      0204: 00 18 00 00 01 f4 00 00 01 f4 00 05 80 80 80 02 [................]
      0214: 11 90 06 80 80 80 01 02 00 00 00 1a 73 67 70 64 [............sgpd]
      0224: 01 00 00 00 72 6f 6c 6c 00 00 00 02 00 00 00 01 [....roll........]
      0234: ff ff 00 00 00 1c 73 62 67 70 00 00 00 00 72 6f [......sbgp....ro]
      0244: 6c 6c 00 00 00 01 00 00 1d eb 00 00 00 01 00 00 [ll..............]
      0254: 00 18 73 74 74 73 00 00 00 00 00 00 00 01 00 00 [..stts..........]
      0264: 1d eb 00 00 04 00 00 00 0e 5c 73 74 73 63 00 00 [.........\stsc..]

...

  | UserData (SubDirectory) -->
  | - Tag 'udta' (60639 bytes):
  |     f7d3: ...
  |     f7e3: 62 68 61 20 36 2d 32 2d 32 30 32 30 00 00 00 2b [bha 6-2-2020...+]
  |     f7f3: 64 73 63 70 00 00 00 00 55 c4 54 68 69 73 20 76 [dscp....U.This v]
  |     f803: 69 64 65 6f 20 69 73 20 61 62 6f 75 74 20 4d 79 [ideo is about My]
  |     f813: 20 4d 6f 76 69 65 00 00 00 00 0e 6b 79 77 64 69 [ Movie.....kywdi]
  |     f823: 4d 6f 76 69 65 00 00 ec 58 74 68 6d 62 00 00 00 [Movie...Xthmb...]
  |     f833: 00 6a 70 65 67 ff d8 ff e0 00 10 4a 46 49 46 00 [.jpeg......JFIF.]
  |     f843: 01 01 00 00 48 00 48 00 00 ff e1 00 80 45 78 69 [....H.H......Exi]
  |     f853: 66 00 00 4d 4d 00 2a 00 00 00 08 00 04 01 1a 00 [f..MM.*.........]
  |     f863: 05 00 00 00 01 00 00 00 3e 01 1b 00 05 00 00 00 [........>.......]
  |     f873: 01 00 00 00 46 01 28 00 03 00 00 00 01 00 02 00 [....F.(.........]

...

  | + [UserData directory]

...

  | | Description = U.This video is about My Movie
  | | - Tag 'dscp' (35 bytes):
  | |     f7f7: 00 00 00 00 55 c4 54 68 69 73 20 76 69 64 65 6f [....U.This video]
  | |     f807: 20 69 73 20 61 62 6f 75 74 20 4d 79 20 4d 6f 76 [ is about My Mov]
  | |     f817: 69 65 00                                        [ie.]
  | | Keywords = iMovie
  | | - Tag 'kywd' (6 bytes):
  | |     f822: 69 4d 6f 76 69 65                               [iMovie]




("..." elides irrelevant or potentially private data)

It looks like the kywd parser in QuickTime.pm is expecting to unpack a lang prefix in the string: and because "iMove".length < 7, it emits "<err>".

https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool/QuickTime.pm#L1585

If there's anything else I can provide to help with this, please let me know.

Thanks, as always, for ExifTool!


Phil Harvey

#1
Thanks for this report.  Could you send me a sample for testing?  philharvey66 at gmail.com

- Phil

Edit: Just for my reference... I had trouble finding the specification for this, but I found one here on page 36, which seems to match up with the way ExifTool is decoding this.

Edit2: If Apple has decided to write this differently, it is likely that other UserData tags will suffer this fate as well.  It would be useful if you could write as much metadata to the sample file as possible.  Thanks.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mceachen

I got the file from a PhotoStructure beta tester, and he didn't want me to send it to anyone else (it's a video of a family member).

How can I send you the metadata header you need, without the video payload?

StarGeek

Quote from: mceachen on February 06, 2021, 07:09:57 PM
I got the file from a PhotoStructure beta tester

Is the file directly from the phone or has PhotoStructure altered it?

Might he be able to give you a new video to pass on to Phil?  For example, a short video of his hand covering the lens.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mceachen

QuoteIs the file directly from the phone or has PhotoStructure altered it?

It's direct from the iDevice.

QuoteMight he be able to give you a new video to pass on to Phil?  For example, a short video of his hand covering the lens.

I'll ask. (I'd used Phil's replace-image script before that retains all metadata but replaces the image data with a single pixel: I didn't know if there was an analogous tool for other file types).

Phil Harvey

I don't have anything like swap_image for video files.

I might be able to do something about this without a sample.  Could you post the full -v3 output?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mceachen


Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

OK.  I've patched ExifTool to handle this format of UserData Keywords.  ExifTool 12.18 (available within a few days) should be able to read this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mceachen

Quote from: Phil Harvey on February 08, 2021, 10:10:48 AM
OK.  I've patched ExifTool to handle this format of UserData Keywords.  ExifTool 12.18 (available within a few days) should be able to read this.

- Phil

Thanks again!  ;D