dateTimeOriginal vs CreateDate - which one is safer as a source of truth ?

Started by lumiere, April 23, 2022, 12:55:52 PM

Previous topic - Next topic

lumiere

Hi all,

I am (still ...) sorting my pictures and videos using "dateTimeOriginal" but found that some of the video files don't have that tag but "CreateDate" instead:

[File:System]   FileModifyDate                  : 2021:07:30 07:06:39+01:00
[File:System]   FileAccessDate                  : 2022:04:23 16:08:15+01:00
[File:System]   FileInodeChangeDate             : 2022:04:23 16:29:04+01:00
[QuickTime]     CreateDate                      : 2012:12:26 14:41:52
[QuickTime]     ModifyDate                      : 2012:12:26 14:41:52
[QuickTime:Track1] TrackCreateDate              : 2012:12:26 14:41:52
[QuickTime:Track1] TrackModifyDate              : 2012:12:26 14:41:52
[QuickTime:Track1] MediaCreateDate              : 2012:12:26 14:41:52
[QuickTime:Track1] MediaModifyDate              : 2012:12:26 14:41:52
[QuickTime:Track2] TrackCreateDate              : 2012:12:26 14:41:52
[QuickTime:Track2] TrackModifyDate              : 2012:12:26 14:41:52
[QuickTime:Track2] MediaCreateDate              : 2012:12:26 14:41:52
[QuickTime:Track2] MediaModifyDate              : 2012:12:26 14:41:52

Once I applied this:

exiftool '-DateTimeOriginal<CreateDate' myfile

I got:

======== f311957528_mdat.mov
[File:System]   FileModifyDate                  : 2022:04:23 16:32:49+01:00
[File:System]   FileAccessDate                  : 2022:04:23 16:32:49+01:00
[File:System]   FileInodeChangeDate             : 2022:04:23 16:32:49+01:00
[QuickTime]     CreateDate                      : 2012:12:26 14:41:52
[QuickTime]     ModifyDate                      : 2012:12:26 14:41:52
[QuickTime:Track1] TrackCreateDate              : 2012:12:26 14:41:52
[QuickTime:Track1] TrackModifyDate              : 2012:12:26 14:41:52
[QuickTime:Track1] MediaCreateDate              : 2012:12:26 14:41:52
[QuickTime:Track1] MediaModifyDate              : 2012:12:26 14:41:52
[QuickTime:Track2] TrackCreateDate              : 2012:12:26 14:41:52
[QuickTime:Track2] TrackModifyDate              : 2012:12:26 14:41:52
[QuickTime:Track2] MediaCreateDate              : 2012:12:26 14:41:52
[QuickTime:Track2] MediaModifyDate              : 2012:12:26 14:41:52
[XMP:XMP-exif]  DateTimeOriginal                : 2012:12:26 14:41:52
[QuickTime:UserData] DateTimeOriginal           : 2012:12:26 14:41:52+00:00
======== f311957528_mdat.mov_original
[File:System]   FileModifyDate                  : 2021:07:30 07:06:39+01:00
[File:System]   FileAccessDate                  : 2022:04:23 16:29:27+01:00
[File:System]   FileInodeChangeDate             : 2022:04:23 16:32:49+01:00
[QuickTime]     CreateDate                      : 2012:12:26 14:41:52
[QuickTime]     ModifyDate                      : 2012:12:26 14:41:52
[QuickTime:Track1] TrackCreateDate              : 2012:12:26 14:41:52
[QuickTime:Track1] TrackModifyDate              : 2012:12:26 14:41:52
[QuickTime:Track1] MediaCreateDate              : 2012:12:26 14:41:52
[QuickTime:Track1] MediaModifyDate              : 2012:12:26 14:41:52
[QuickTime:Track2] TrackCreateDate              : 2012:12:26 14:41:52
[QuickTime:Track2] TrackModifyDate              : 2012:12:26 14:41:52
[QuickTime:Track2] MediaCreateDate              : 2012:12:26 14:41:52
[QuickTime:Track2] MediaModifyDate              : 2012:12:26 14:41:52

So I either set "CreateDate" to be equal to "dateTimeOriginal" or vice versa.
What is your recommendation - which way would be better ?

StarGeek

In video files, you want to use CreateDate, but you need to understand that in video files, CreateDate and ModifyDate are supposed to be set to UTC.  DateTimeOriginal, on the other hand, is supposed to be set to local time and include a time zone.

For example, in my -07:00 time zone, if CreateDate/ModifyDate were set to 2022:04:23 12:00:00  (UTC), then DateTimeOriginal would be set to 2022:04:23 05:00:00-07:00.

When copying from CreateDate to DateTimeOriginal, you would want to add the -api QuickTimeUTC option.

If the computer is located in the same time zone as where the picture was taken, ignoring adjustments for Daylight savings, then you would use
exiftool '-DateTimeOriginal<CreateDate' -api QuickTimeUTC /path/to/files/

If the time zone where the picture was taken is different, then that time zone needs to be included
exiftool '-DateTimeOriginal<$CreateDate-07:00' -api QuickTimeUTC /path/to/files/

As I said, this applies to video files.  In image files, all of the above time stamps are supposed to be set to local time.
* 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).

Moonbase59

If it's just for file renaming/sorting purposes, I use a simple fallback in my "exifrename" script (I rename and sort based on datetime + camera model): DateTimeOriginal → CreateDate → FileModifyDate (in case there is no date tag altogether). I also use the "MWG" (Metadata Working Group) tags, because exiftool nicely reads the proposed (multiple) tags and their recommended sequence, so I always get the "best" datetime info out of oddly tagged files.

Feel free to "steal" any part of my code (Linux bash script) that you can use:


#!/bin/bash

# exifrename

# 2022-04-11 Matthias C. Hormann (aka Moonbase59)

# rename image and video files from original date taken, with fallbacks
#   exifrename [file, folder, params]
# where [params] are standard exiftool parameters, i.e. '-ext jpg'

# Format (in sequence of fallbacks):
#   YYYYMMDD-HHMMSS.sss-camera.ext
#   YYYYMMDD-HHMMSS.sss.ext
#   YYYYMMDD-HHMMSS-camera.ext
#   YYYYMMDD-HHMMSS.ext
#   YYYYMMDD-HHMMSS.ext (taken from file system's modify date if no tags in file)
#
# The filename extension will always be lowercased, for ease of use, i.e. .JPG -> .jpg
#
# In case of duplicate files, a copy number in the form of '-#' will be added
# to the file name, for all formats shown above, i.e.
#   YYYYMMDD-HHMMSS.ss-camera-#.ext

# define me
me=$(basename "$0")

# check if exiftool installed
command -v exiftool >/dev/null 2>&1 || { echo >&2 "$me requires \"exiftool\" but it's not installed. Aborting."; exit 2; }

# check if we can use sub-second dates
# (Versions 12.35 and above added %f code to -d option for fractional seconds)
REQVERSION="12.35"
CURVERSION="$(exiftool -ver)"
if [ ! "$(printf '%s\n' "$REQVERSION" "$CURVERSION" | sort -V | head -n1)" = "$REQVERSION" ]; then
  echo >&2 "Sub-second dates only available in \"exiftool\" version $REQVERSION or newer."
  echo >&2 "You have version $CURVERSION, adjusting for full-second precision."
  DATESTRING='%Y%m%d-%H%M%S'
else
  DATESTRING='%Y%m%d-%H%M%S%3f'
fi

# If it exists, we prefer DateTimeOriginal over the composite tag CreateDate,
# because some cameras store nonsense here (OnePlus One has create date 2002:12:08 12:00:00
# and stores no model name).

# We use the Metadata Working Group (MWG) composite tags here, to allow
# certain overlapping EXIF, IPTC and XMP tags to be reconciled when reading,
# and synchronized when writing.
# These also use SubSecond dates, if available.
# See https://exiftool.org/TagNames/MWG.html

exiftool -P -d "$DATESTRING" \
  '-FileName<${FileModifyDate}%-c.%le' \
  '-FileName<${MWG:CreateDate}%-c.%le' \
  '-FileName<${MWG:CreateDate}-${Model}%-c.%le' \
  '-FileName<${MWG:DateTimeOriginal}%-c.%le' \
  '-FileName<${MWG:DateTimeOriginal}-${Model}%-c.%le' \
  $@