default date for .mp4 files without a date is not formatted using -date-format

Started by vicarage, September 06, 2022, 10:50:58 AM

Previous topic - Next topic

vicarage

Linux Mint
/home/john/Downloads/2/Image-ExifTool-12.44/exiftool -ver
12.44

/home/john/Downloads/2/Image-ExifTool-12.44/exiftool -CreateDate -dateFormat "+%FT%TZ" ../Q/Q5631813/Promo.mp4
Create Date                     : 0000:00:00 00:00:00

/home/john/Downloads/2/Image-ExifTool-12.44/exiftool -CreateDate -dateFormat "+%FT%TZ" 1.mp4
Create Date                     : +1900-12-15T03:27:12Z

The formatting is working for a mp4 file with a date, but without one you return a placeholder value, but don't format it according to the required date format


Phil Harvey

The library used for date/time formatting generally only works for dates between 1970 and 2038.

But even if it worked on a wider range, the date 0000:00:00 is invalid, so the formatting library would reject it anyway.

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

vicarage

My problem is that I get the 0000 stuff from many videos, and I don't know whether that is explicitly coded as that by the creator/last program to rewrite the video, or it is a response to a missing value somewhere in library chain and exiftool itself. But the consequence is that these missing dates come out in a different format to valid ones, so I need a clumsy extra stage to reformat them to be consistent with the rest before I decide whether to use it. If its truly invalid, perhaps exiftool should not provide it at all rather than provide it in a different format to valid dates.

PS I'd hope that dates between 1870 and 1970 would work, because I can imagine creators adjusting the creation date to when the original footage was shot, but I don't have any examples of that to see how they are handled.


wywh

Yes, that is the result if 'QuickTime:CreateDate' is missing. I guess have sometimes seen that in movies from yt-dlp and then converted from VP9 to H.264 or H.265 with ffmpeg. But I always put the date in the filename and then use that to set the metadata dates with:

exiftool -api QuickTimeUTC=1 '-AllDates<FileName' '-Track*Date<FileName' '-Media*Date<FileName' '-Keys:CreationDate<FileName' -execute '-FileCreateDate<FileName' '-FileModifyDate<FileName' -common_args -m -P -overwrite_original_in_place -wm w .

For example a movie with a date:

exiftool -a -G1 -s -api QuickTimeUTC=1 -time:all 2000-0101-1200-00.mp4
[QuickTime]     CreateDate                      : 2000:01:01 12:00:00+02:00


...if the date is then deleted:

exiftool -m -overwrite_original_in_place -QuickTime:CreateDate= 2000-0101-1200-00.mp4

...and the missing date checked with different options:

exiftool -a -G1 -s -api QuickTimeUTC=1 -time:all 2000-0101-1200-00.mp4
[QuickTime]     CreateDate                      : 1904:01:01 01:39:49+01:39

exiftool -a -G1 -s -api QuickTimeUTC=0 -time:all 2000-0101-1200-00.mp4
[QuickTime]     CreateDate                      : 0000:00:00 00:00:00

exiftool -CreateDate -dateFormat '+%FT%TZ' 2000-0101-1200-00.mp4
Create Date                     : 0000:00:00 00:00:00


I have done some tests for oldest supported movie dates in macOS. There is some variance how recent macOS 10.14-12 behave.

It is best to use 'Keys:CreationDate' before 1970 although in macOS 12 Monterey 'QuickTime:CreateDate' works even for '1904-01-01 00.00.01' or later and also Photos.app grabs that date (*).

For Google Photos 'QuickTime:CreateDate' works only for '1970-01-01 00.00.00' or later.

exiftool -m -overwrite_original_in_place '-QuickTime:CreateDate=1904:01:01 00:00:01+00:00' 1904-0101-0000-01.mp4

exiftool -a -G1 -s -api QuickTimeUTC=1 -time:all 1904-0101-0000-01.mp4
[QuickTime]     CreateDate                      : 1904:01:01 01:39:50+01:39


With '-api QuickTimeUTC=0' that is displayed as:

exiftool -a -G1 -s -api QuickTimeUTC=0 -time:all 1904-0101-0000-01.mp4
[QuickTime]     CreateDate                      : 1970:01:01 00:00:01


Before those dates 'Keys:CreationDate' works even for '0001-00-00 00.00.00' or later in Photos.app.

In Google Photos '1902-01-01 00.00.00' or later  works with '-Keys:CreationDate'. Earlier dates might work even to year 0001 but then Google Photos might randomly display a wrong date and even if it displays the correct date, it might sort that movie incorrectly.

exiftool -m -overwrite_original_in_place '-Keys:CreationDate=0001:01:01 00:00:00+00:00' 0001-0101-0000-00.mp4

exiftool -a -G1 -s -api QuickTimeUTC=1 -time:all 0001-0101-0000-00.mp4
[Keys]          CreationDate                    : 0001:01:01 00:00:00+00:00


So movies before 1970 obey the 'Keys:CreationDate'. .m4v and .mov display correct time combined with the timezone but in .mp4 the timezone must be subtracted from the time.

.mp4 (not .m4v and .mov) before 1921-0501-00-00 also need 20 minutes 11 seconds added to the previously calculated time combined with a modified timezone +01:40.

(*) YMMV because in the late 1800's many countries switched to local timezones but in my location that happened May 1st 1921 with +20 min 10.9 sec adjustment.

- Matti

vicarage

I first noticed this on a privately provided file. But it occurs a lot with get-iplayer and youtube-dl, and we know how lax Internet companies are with metadata. Generally there are lots of videos/images and they aren't mine, so I don't plan to correct them or really care if they are wrong, just that they are consistently wrong!