Bug with corrupted mp4 and changing file's modify/create date

Started by kapela86, January 11, 2025, 02:12:08 PM

Previous topic - Next topic

kapela86

I have mp4 files copied from iPhone. I wanted to modify FileModifyDate and FileCreateDate of every mp4 according to QuickTime:CreateDate. So I used:
exiftool.exe "-FileModifyDate<QuickTime:CreateDate" "-FileCreateDate<QuickTime:CreateDate" -api QuickTimeUTC -progress -m -ext mov -ext mp4 .Most files were processed properly, but those that were from WhatsApp had their date changed to "1904-01-01 01:00:00". And some of them showed this warning:
Warning: Unknown trailer with truncated '\x16\x00\x00\x01' data at offset 0x1ad275 - ./2023-11__PXLR3104.mp4
I checked them with MediaInfo and either they don't have Encoded Date or show "Conformance errors".

From my point of view, this looks like a bug in exiftool. When there is no QuickTime:CreateDate or it's corruped, then exiftool should just print error/warning and skip the file instead of modifying the date to some arbitrary date.

StarGeek

Quote from: kapela86 on January 11, 2025, 02:12:08 PMFrom my point of view, this looks like a bug in exiftool. When there is no QuickTime:CreateDate or it's corruped, then exiftool should just print error/warning and skip the file instead of modifying the date to some arbitrary date.

The Quicktime:CreateDate/Quicktime:ModifyDate tags must always exist in the file. Things like WhatApp will strip away metadata for privacy, but since these tags cannot be removed, they are set to 0000:00:00 00:00:00. So there is a date and it is not corrupted.

When the -api QuickTimeUTC option is used with this all 0 time stamp, then result is a time stamp in 1904/1905.

You can either first set a correct time stamp in the WhatsApp files, usually by copying the data from the file (see this post for an example command) or you can skip those files with the -if option

Assuming Windows CMD
exiftool -if "$CreateDate gt '1906'" "-FileModifyDate<QuickTime:CreateDate" "-FileCreateDate<QuickTime:CreateDate" -api QuickTimeUTC -progress -m -ext mov -ext mp4 .
"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

kapela86

Quote from: StarGeek on January 11, 2025, 02:31:07 PMThe Quicktime:CreateDate/Quicktime:ModifyDate tags must always exist in the file.
They don't exist in those files. I uploaded one of those files that I can safely share:
https://mega.nz/file/6p8w2JyB#gvlSDAKCT7-ze_kPPtEx07gpNrFpQFqyn3_ZAiRNzxs
Check it with MediaInfo, even with Text + Advanced Mode it doesn't show them. They just aren't there.

That "if" statement is a nice solution for this, I will implement it in my cmd files. But regardless, this bug should be fixed by dev.

Phil Harvey

> exiftool LOQH7561.MP4 -quicktime:createdate -api quicktimeutc
Create Date                     : 1903:12:31 19:00:00-05:00

That is the QuickTime time zero.

So ExifTool is setting the filesystem date/time as expected.

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

StarGeek

Quote from: kapela86 on January 11, 2025, 03:13:44 PMThey don't exist in those files.

Your other programs are hiding the 0 date from you. Look at the file with exiftool. Phil's command shows the output with -api QuicktimeUTC. Without it you see

C:\>exiftool -time:all -G1 -a -s Y:\!temp\x\y\LOQH7561.MP4
[System]        FileModifyDate                  : 2025:01:11 13:06:45-08:00
[System]        FileAccessDate                  : 2025:01:11 13:09:25-08:00
[System]        FileCreateDate                  : 2025:01:11 13:06:45-08:00
[QuickTime]     CreateDate                      : 0000:00:00 00:00:00
[QuickTime]     ModifyDate                      : 0000:00:00 00:00:00
[Track1]        TrackCreateDate                 : 0000:00:00 00:00:00
[Track1]        TrackModifyDate                 : 0000:00:00 00:00:00
[Track1]        MediaCreateDate                 : 0000:00:00 00:00:00
[Track1]        MediaModifyDate                 : 0000:00:00 00:00:00
[Track2]        TrackCreateDate                 : 0000:00:00 00:00:00
[Track2]        TrackModifyDate                 : 0000:00:00 00:00:00
[Track2]        MediaCreateDate                 : 0000:00:00 00:00:00
[Track2]        MediaModifyDate                 : 0000:00:00 00:00:00

You can also use exiftool -v3 (-verbose3) option to look directly at the location of the time stamps
  + [Movie directory]
  | MovieHeader (SubDirectory) -->
  | - Tag 'mvhd' (100 bytes):
  |     0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ac 44 [...............D]
  |     0050: 00 07 0c 00 00 01 00 00 01 00 00 00 00 00 00 00 [................]
  |     0060: 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 [................]
  |     0070: 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 [................]
  |     0080: 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 [....@...........]
  |     [snip 20 bytes]
  | + [BinaryData directory, 100 bytes]
  | | MovieHeaderVersion = 0
  | | - Tag 0x0000 (1 bytes, int8u[1]):
  | |     0040: 00                                              [.]
  | | CreateDate = 0
  | | - Tag 0x0001 (4 bytes, int32u[1]):
  | |     0044: 00 00 00 00                                     [....]
  | | ModifyDate = 0
  | | - Tag 0x0002 (4 bytes, int32u[1]):
  | |     0048: 00 00 00 00                                     [....]
"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

kapela86

Even if what you are saying is true (I'm not saying it isn't), then exiftool shouldn't just blindly set that obviously incorrect date.

Also, mp4box shows Created: UNKNOWN DATE, not some arbitrary date or 0000:00:00 00:00:00.
And "0" can also mean null.

mp4box.exe -info LOQH7561.MP4
[iso file] Unknown top-level box type beam
[ODF] Error reading descriptor (tag 6 size 2): Invalid MPEG-4 Descriptor
# Movie Info - 2 tracks - TimeScale 44100
Duration 00:00:10.472
Fragmented: no
Progressive (moov before mdat)
Major Brand mp42 - version 0 - compatible brands: mp42 isom
Created: UNKNOWN DATE

# Track 1 Info - ID 1 - TimeScale 30000
Media Duration 00:00:10.466
Track flags: Enabled In Movie In Preview
Media Samples: 313
Visual Track layout: x=0 y=0 width=480 height=864
Media Type: vide:avc1
        Visual Sample Entry Info: width=480 height=864 (depth=24 bits)
        AVC/H264 Video - Visual Size 480 x 864
        AVC Info: 1 SPS - 1 PPS - Profile High @ Level 3
        NAL Unit length bits: 32
        Chroma format YUV 4:2:0 - Luma bit depth 8 - chroma bit depth 8
        SPS#1 hash: 380F112ADAEB88576A7EDF8035A79E1C41648173
        PPS#1 hash: F275FDD4B47B1ABC876430F678C8B6ED3A300732
        RFC6381 Codec Parameters: avc1.64001E
        Average GOP length: 313 samples
        Max sample duration: 2000 / 30000

# Track 2 Info - ID 2 - TimeScale 44100
Media Duration 00:00:10.472
Track flags: Enabled In Movie In Preview
Media Samples: 451 - CFR 43.066406/sec
Media Type: soun:mp4a
        MPEG-4 Audio AAC LC (AOT=2 implicit) - 2 Channel(s) - SampleRate 44100
        RFC6381 Codec Parameters: mp4a.40.2
        All samples are sync
        Max sample duration: 1024 / 44100

Phil Harvey

I've just released ExifTool 13.12 which will avoid returning zero QuickTime date/time values when the -api strictdate option is used.

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