ExifTool Forum

ExifTool => Newbies => Topic started by: sjw on January 03, 2024, 08:30:48 AM

Title: Error when trying to set CreateDate on mp4 - even with -m option
Post by: sjw on January 03, 2024, 08:30:48 AM
I recently needed to restore my WhatsApp to my phone but it restores everything with no metadata at all so all photos and videos in Google Photos appear with the restore date  >:(
To add the metadata back, I have run
c:\users\ste\desktop\exiftool.exe -m -api QuickTimeUTC "-alldates<${filename;$_=substr($_,0,12)} 12:00" "-filemodifydate<${filename;$_=substr($_,0,12)} 12:00" "-filecreatedate<${filename;$_=substr($_,0,12)} 12:00" -overwrite_original VID-20230326-WA0003.mp4 but I get an error on some files.  If I remove the -alldates part it is OK.
c:\users\ste\desktop\exiftool.exe -m -api QuickTimeUTC "-createdate=2023:03:26 03:00:00" VID-20230326-WA0003.mp4 -m fails.
The error is Error: Truncated '0x0013ee00' atom - VID-20230326-WA0003.mp4Is there anything that can be done for force populate the Quicktime Create Date tag?

Full detail or example problem file:
ExifTool Version Number         : 12.72
File Name                       : VID-20230326-WA0003.mp4
Directory                       : .
File Size                       : 4.1 MB
File Modification Date/Time     : 2023:03:26 12:00:00+01:00
File Access Date/Time           : 2024:01:03 13:27:41+00:00
File Creation Date/Time         : 2023:03:26 12:00:00+01:00
File Permissions                : -rw-rw-rw-
File Type                       : MP4
File Type Extension             : mp4
MIME Type                       : video/mp4
Major Brand                     : MP4 v2 [ISO 14496-14]
Minor Version                   : 0.0.0
Compatible Brands               : mp42, isom
Movie Header Version            : 0
Create Date                     : 0000:00:00 00:00:00
Modify Date                     : 0000:00:00 00:00:00
Time Scale                      : 44100
Duration                        : 11.99 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Track Header Version            : 0
Track Create Date               : 0000:00:00 00:00:00
Track Modify Date               : 0000:00:00 00:00:00
Track ID                        : 1
Track Duration                  : 11.97 s
Track Layer                     : 0
Track Volume                    : 100.00%
Image Width                     : 848
Image Height                    : 480
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Compressor ID                   : avc1
Source Image Width              : 848
Source Image Height             : 480
X Resolution                    : 72
Y Resolution                    : 72
Bit Depth                       : 24
Color Profiles                  : nclx
Color Primaries                 : BT.709
Transfer Characteristics        : BT.709
Matrix Coefficients             : BT.709
Video Full Range Flag           : 0
Video Frame Rate                : 30
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 0000:00:00 00:00:00
Media Modify Date               : 0000:00:00 00:00:00
Media Time Scale                : 44100
Media Duration                  : 11.99 s
Media Language Code             : und
Handler Type                    : Audio Track
Balance                         : 0
Audio Format                    : mp4a
Audio Channels                  : 2
Audio Bits Per Sample           : 16
Audio Sample Rate               : 44100
Media Data Size                 : 4047578
Media Data Offset               : 5228
Warning                         : Truncated '\x00\x13\xee\x00' data
Image Size                      : 848x480
Megapixels                      : 0.407
Avg Bitrate                     : 2.7 Mbps
Rotation                        : 0
Title: Re: Error when trying to set CreateDate on mp4 - even with -m option
Post by: Phil Harvey on January 03, 2024, 08:33:33 AM
Could you send me the video so I can take a look?  My email is philharvey66 at gmail.com

- Phil
Title: Re: Error when trying to set CreateDate on mp4 - even with -m option
Post by: sjw on January 03, 2024, 08:56:51 AM
Sure thing Phil, just done that.
Also, in the command above, I used the <${filename;$_=substr($_,0,12)} part instead of simple <filename to make the command ignore the last part of the filenames because if it was WA0063 for example, I think it sees the 63 and tries to use it to set the time with an illegal character (above 59?).  Is this about the best way?
Title: Re: Error when trying to set CreateDate on mp4 - even with -m option
Post by: Phil Harvey on January 03, 2024, 09:26:31 AM
The file contains some sort of trailing information that I don't recognize.  It isn't formatted as a proper QuickTime atom so ExifTool gives the error when trying to write it.  This is the conservative thing to do because a corrupted file would look just like this, and I don't want ExifTool to write corrupted files because then ExifTool could get blamed for corrupting them.

So the bottom line is there is no way to get ExifTool to write metadata to this file.  You can still, however, use it to set the system date/time information.

Quote from: sjw on January 03, 2024, 08:56:51 AMAlso, in the command above, I used the <${filename;$_=substr($_,0,12)} part instead of simple <filename to make the command ignore the last part of the filenames because if it was WA0063 for example, I think it sees the 63 and tries to use it to set the time with an illegal character (above 59?).  Is this about the best way?

This looks good to me.

- Phil
Title: Re: Error when trying to set CreateDate on mp4 - even with -m option
Post by: sjw on January 03, 2024, 09:37:51 AM
OK, thanks Phil, much appreciated.  I guess I could look to see if there was a theme (from same person, camera etc.) but it looks like there's nothing can be done anyway.  I wonder what that information is and why it's there.
Thanks again.
Title: Re: Error when trying to set CreateDate on mp4 - even with -m option
Post by: Phil Harvey on January 03, 2024, 09:51:43 AM
Looking further into the trailer data, it looks like parts of the audio track of another MP4 file.

I have seen this sort of thing happen when a file is recovered from a corrupted disk, or when a previously deleted file is recovered.

- Phil
Title: Re: Error when trying to set CreateDate on mp4 - even with -m option
Post by: sjw on January 03, 2024, 01:11:12 PM
Update in case anyone else else stumbles on this, I downloaded ffmpeg and ran the following command:
ffmpeg -i <full path to>video.mp4 -acodec copy -vcodec copy <full path to>newvideo.mp4
From what I can see there are no adverse effects on the video.
exiftool then writes the tags as I'd hoped.
Code of fixed file is below:
ExifTool Version Number         : 12.72
File Name                       : VID-20230326-WA00031.mp4
Directory                       : .
File Size                       : 4.1 MB
File Modification Date/Time     : 2023:03:26 12:00:00+01:00
File Access Date/Time           : 2024:01:03 18:07:28+00:00
File Creation Date/Time         : 2023:03:26 12:00:00+01:00
File Permissions                : -rw-rw-rw-
File Type                       : MP4
File Type Extension             : mp4
MIME Type                       : video/mp4
Major Brand                     : MP4 Base Media v1 [IS0 14496-12:2003]
Minor Version                   : 0.2.0
Compatible Brands               : isom, iso2, avc1, mp41
Movie Header Version            : 0
Time Scale                      : 1000
Duration                        : 11.99 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Track Header Version            : 0
Track Create Date               : 0000:00:00 00:00:00
Track Modify Date               : 0000:00:00 00:00:00
Track ID                        : 1
Track Duration                  : 11.97 s
Track Layer                     : 0
Track Volume                    : 0.00%
Image Width                     : 848
Image Height                    : 480
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Compressor ID                   : avc1
Source Image Width              : 848
Source Image Height             : 480
X Resolution                    : 72
Y Resolution                    : 72
Bit Depth                       : 24
Color Profiles                  : nclx
Color Primaries                 : BT.709
Transfer Characteristics        : BT.709
Matrix Coefficients             : BT.709
Video Full Range Flag           : 0
Buffer Size                     : 0
Max Bitrate                     : 2640237
Average Bitrate                 : 2640237
Video Frame Rate                : 30
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 0000:00:00 00:00:00
Media Modify Date               : 0000:00:00 00:00:00
Media Time Scale                : 44100
Media Duration                  : 11.99 s
Media Language Code             : und
Handler Description             : SoundHandler
Balance                         : 0
Audio Format                    : mp4a
Audio Channels                  : 2
Audio Bits Per Sample           : 16
Audio Sample Rate               : 44100
Handler Type                    : Metadata
Handler Vendor ID               : Apple
Encoder                         : Lavf60.16.100
XMP Toolkit                     : Image::ExifTool 12.72
Date/Time Original              : 2023:03:26 12:00
Create Date                     : 2023:03:26 12:00
Modify Date                     : 2023:03:26 12:00
Media Data Size                 : 4047578
Media Data Offset               : 14806
Image Size                      : 848x480
Megapixels                      : 0.407
Avg Bitrate                     : 2.7 Mbps
Rotation                        : 0
As ever, thanks for the help Phil.