Clarification on exiftool behavior

Started by pjsemmer, February 28, 2025, 06:25:42 PM

Previous topic - Next topic

pjsemmer

Hi - I started using exiftool earlier this week, and being new to it, I didn't realize right away that it rewrites the entire file when changing the metadata of a file.  What I'm doing specifically is clearing the Title from MP4 files, so that when I add them to my Plex server, it can get the title from external sources like TVDB or  TheMovieDatabase.  I'm sure everyone knows that MakeMKV adds its own Title based on the disc number and/or track number on the disc, so it needs to be cleared after conversion to MP4 by Handbrake.  Why there's no option in MakeMKV to just leave it blank is a mystery.

Anyway, what I'm seeing after doing this to files is that if I try to edit the metadata using the Properties in Windows File Explorer, it now rewrites the file as well, whereas before the metadata could be edited and changed instantaneously.

What I suspect is that based on point #2 of FAQ #31, the metadata is being written at the beginning of the file, whereas before it was touched by exiftool, it was at the end.  I'm guessing that if the metadata is at the end of the file, it is easy enough to modify without rewriting the file.  If the metadata is now at the beginning, it can't be modified in place because if the size of the metadata changes, the rest of the file can't just be expanded or contracted without corrupting the file.

Can you please clarify if what I'm saying is correct?

Thanks in advance.

StarGeek

Quote from: pjsemmer on February 28, 2025, 06:25:42 PMWhy there's no option in MakeMKV to just leave it blank is a mystery.

It's right there. You leave the Properties→Name blank
makemkv-2025-02-28_15.38.34.png

QuoteCan you please clarify if what I'm saying is correct?

It is not. Exiftool always rewrites the file. It never edits in place. The title of that FAQ is "Why does ExifTool rewrite the entire file".

You might look into the command line parts of MKVToolNix to preprocess the file. I believe that those do edit in place. I've used it to remove some color profiles from files that really messes up the display from my Roku, and it is extremely fast.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

pjsemmer

#2
Stargeek Edit: I tried to fix the bad quoting and accidentally deleted your image, sorry about that

Quote from: StarGeek on February 28, 2025, 06:48:43 PM
Quote from: pjsemmer on February 28, 2025, 06:25:42 PMWhy there's no option in MakeMKV to just leave it blank is a mystery.

It's right there. You leave the Properties→Name blank
makemkv-2025-02-28_15.38.34.png

I was aware of that field and did look into leaving it blank, but that needs to be done for every track on the disc.  That would be somewhat of a hassle if the disc has many tracks. It also wipes out the description of the track and the resulting .mkv file only has "title_XX" instead of the disc title and disc number in the filename.  If you're ripping a TV series with multiple seasons and discs, you wouldn't be able to put all .mkv files in the same directory because MakeMKV will always start with track 00 each time you load a new disc.  You'd need to have separate sub-directories for each disc.

What I really meant was some kind of global option in the dialog that you can check to leave the Title in the metadata blank for all tracks but also keep the description for the filename. 

Notice below, how I left the field blank but it wiped out the description only for that 1 track.  The others still have the description and if I select the others, it will fill that description in the name field.

Not a valid attachment ID.

Quote
QuoteCan you please clarify if what I'm saying is correct?

It is not. Exiftool always rewrites the file. It never edits in place. The title of that FAQ is "Why does ExifTool rewrite the entire file".

You might look into the command line parts of MKVToolNix to preprocess the file. I believe that those do edit in place. I've used it to remove some color profiles from files that really messes up the display from my Roku, and it is extremely fast.

I believe you might have misunderstood what I was trying to say.  I am fully aware that exiftool rewrites the entire file but once it does, that same behavior occurs if you right-click the file in Windows and go into the Properties/Detail and try to edit the metadata.  I'm trying to find out why that happens and the only conclusion I could come to is the positioning of the metadata in both the "pre-exiftool" and "post-exiftool" file, based on what I read in FAQ 31.2.  That is the answer that I'm looking for.

StarGeek

You can use the -v3 (-verbose3) option to see where the data is located in the file. I believe you would look whether it was before or after the mdat block

For example, after clearing the file of all data and then setting Title, which sets the ItemList:Title and XMP:Title, both appear before the mdat
  | | | + [ItemList directory]
  | | | | Title = TestTitle
  | | | | - Tag '\xa9nam', Type='data', Flags=0x1 (UTF-8), Lang=0x0000 (9 bytes):
  | | | |     0b9f: 54 65 73 74 54 69 74 6c 65                      [TestTitle]
  XMP (SubDirectory) -->
  - Tag 'uuid' (2877 bytes):
      0bb0: be 7a cf cb 97 a9 42 e8 9c 71 99 94 91 e3 af ac [.z....B..q......]
      0bc0: 3c 3f 78 70 61 63 6b 65 74 20 62 65 67 69 6e 3d [<?xpacket begin=]
      0bd0: 27 ef bb bf 27 20 69 64 3d 27 57 35 4d 30 4d 70 ['...' id='W5M0Mp]
      0be0: 43 65 68 69 48 7a 72 65 53 7a 4e 54 63 7a 6b 63 [CehiHzreSzNTczkc]
      0bf0: 39 64 27 3f 3e 0a 3c 78 3a 78 6d 70 6d 65 74 61 [9d'?>.<x:xmpmeta]
      [snip 2797 bytes]
  + [XMP directory, 2861 bytes]
  | XMPToolkit = Image::ExifTool 13.21
  | Title = TestTitle
  | - Tag 'x:xmpmeta/rdf:RDF/rdf:Description/dc:title/rdf:Alt/rdf:li 10'
  MediaDataSize = 2096733
  MediaDataOffset = 5877
  MediaData = ..e..7...R8V....b6.....t<..},c..x+.(....Xc.&.|..l...oDr....7.....zx.4-,.6[snip]
  - Tag 'mdat' (2096733 bytes):
      16f5: 00 00 ae fb 65 88 84 37 b5 06 dc 52 38 56 d2 7f [....e..7...R8V..]
      1705: 08 d5 62 36 e4 80 08 ee f7 74 3c 1f 98 7d 2c 63 [..b6.....t<..},c]
      1715: a8 fe 78 2b ff 28 de ca b2 a8 58 63 97 26 d5 7c [..x+.(....Xc.&.|]
      1725: e7 a3 6c fc b7 1e 6f 44 72 f9 f2 ff 83 37 85 02 [..l...oDr....7..]
      1735: 9a ad ea 7a 78 cb 34 2d 2c 92 36 ff 64 c9 bb c2 [...zx.4-,.6.d...]
      [snip 2096653 bytes]
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

@pjsemmer: Your theory sounds plausible although I can't comment on how Windows writes metadata to files.

ExifTool always writes the metadata at the start of the file.

- 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 ($).