Shifting time in video: AllDates, time:all or *date* ?

Started by busywait, January 09, 2018, 12:27:45 PM

Previous topic - Next topic

busywait

Hello,

I've got a bunch of image and video files created with an incorrect time (a 12 hour time offset), recorded with various cameras and phones.

Previously, for photo images, I've used the AllDates shortcut tag to fix up the offset with exiftool -AllDates+=12 a.jpg, and I never thought about the other dates that aren't being changed, like ExifIFD:CreateDate. [Edit: I meant Maker Notes dates, and IFD1:ModifyDateDate, see my later reply]

For recorded video clips I see that there are also additional dates, attributes of each stream in the video file, and they don't get updated by -AllDates. Are there any good reasons for also updating "Track Create Date", Track Modify Date", "Media Modify Date", and "Media Modify Date"?
C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -time:all -G0:1 -s tester.mp4
[File:System]   FileModifyDate                  : 2018:01:09 13:47:15+00:00
[File:System]   FileAccessDate                  : 2018:01:09 16:18:47+00:00
[File:System]   FileCreateDate                  : 2018:01:09 13:47:20+00:00
[QuickTime]     CreateDate                      : 2018:01:09 13:42:17
[QuickTime]     ModifyDate                      : 2018:01:09 13:42:17
[QuickTime:Track1] TrackCreateDate              : 2018:01:09 13:42:17
[QuickTime:Track1] TrackModifyDate              : 2018:01:09 13:42:17
[QuickTime:Track1] MediaCreateDate              : 2018:01:09 13:42:17
[QuickTime:Track1] MediaModifyDate              : 2018:01:09 13:42:17
[QuickTime:Track2] TrackCreateDate              : 2018:01:09 13:42:17
[QuickTime:Track2] TrackModifyDate              : 2018:01:09 13:42:17
[QuickTime:Track2] MediaCreateDate              : 2018:01:09 13:42:17
[QuickTime:Track2] MediaModifyDate              : 2018:01:09 13:42:17


Are there ever times when I'd run in to trouble if I do (or don't) update those dates?

I can see that -times:all offers a simple shortcut to assigning or shifting all writable dates, but there is a small annoyance with shifting:

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -time:all+=12 tester.mp4
    1 image files updated

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -time:all -G0:1 -s tester.mp4
[File:System]   FileModifyDate                  : 2018:01:09 17:01:32+00:00
[File:System]   FileAccessDate                  : 2018:01:09 17:01:32+00:00
[File:System]   FileCreateDate                  : 2018:01:09 13:47:20+00:00
[QuickTime]     CreateDate                      : 2018:01:10 01:42:17
[QuickTime]     ModifyDate                      : 2018:01:10 01:42:17
[QuickTime:Track1] TrackCreateDate              : 2018:01:10 01:42:17
[QuickTime:Track1] TrackModifyDate              : 2018:01:10 01:42:17
[QuickTime:Track1] MediaCreateDate              : 2018:01:10 01:42:17
[QuickTime:Track1] MediaModifyDate              : 2018:01:10 01:42:17
[QuickTime:Track2] TrackCreateDate              : 2018:01:10 01:42:17
[QuickTime:Track2] TrackModifyDate              : 2018:01:10 01:42:17
[QuickTime:Track2] MediaCreateDate              : 2018:01:10 01:42:17
[QuickTime:Track2] MediaModifyDate              : 2018:01:10 01:42:17
[XMP:XMP-iptcExt] ArtworkCircaDateCreated       : 12


Why has ArtworkCircaDateCreated been assigned a value? It doesn't get a value if I use -wm w, but is it being assigned by mistake?

What's the preferred way of fixing offsets when my camera clocks are set wrong?

Phil Harvey

Quote from: busywait on January 09, 2018, 12:27:45 PM
Previously, for photo images, I've used the AllDates shortcut tag to fix up the offset with exiftool -AllDates+=12 a.jpg, and I never thought about the other dates that aren't being changed, like ExifIFD:CreateDate.

But CreateData is included in the AllDates shortcut (see here).

QuoteFor recorded video clips I see that there are also additional dates
[...]
Are there ever times when I'd run in to trouble if I do (or don't) update those dates?

I can't answer that.

QuoteWhy has ArtworkCircaDateCreated been assigned a value? It doesn't get a value if I use -wm w,  but is is being assigned by mistake?

This must be a list-type tag, for which (unfortunately) += is used to add a new value.

I would recommend this to change the MP4 date/times:

exiftool -quicktime:time:all+=12 DIR

You're lucky that your local time zone is UTC, because then you don't have to worry about whether or not the QuickTimeUTC option is necessary when extracting these times.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

busywait

#2
Quote from: Phil Harvey on January 09, 2018, 01:31:38 PM
Quote from: busywait on January 09, 2018, 12:27:45 PM
Previously, for photo images, I've used the AllDates shortcut tag to fix up the offset with exiftool -AllDates+=12 a.jpg, and I never thought about the other dates that aren't being changed, like ExifIFD:CreateDate.

But CreateData is included in the AllDates shortcut (see here).


Sorry, I meant the IFD1:ModifyDate, and also Maker Notes attributes, like the "SonyDateTime":
C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -time:all -G0:1 -s a.jpg
[File:System]   FileModifyDate                  : 2018:01:03 21:55:02+00:00
[File:System]   FileAccessDate                  : 2017:12:15 22:26:20+00:00
[File:System]   FileCreateDate                  : 2017:12:15 13:50:40+00:00
[EXIF:IFD0]     ModifyDate                      : 2018:01:03 21:55:03
[EXIF:ExifIFD]  DateTimeOriginal                : 2018:01:03 21:55:03
[EXIF:ExifIFD]  CreateDate                      : 2018:01:03 21:55:03
[MakerNotes:Sony] SonyDateTime                  : 2018:01:03 21:55:03
[EXIF:IFD1]     ModifyDate                      : 2018:01:03 21:55:03

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -AllDates+=12 a.jpg
    1 image files updated

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -time:all -G0:1 -s a.jpg
[File:System]   FileModifyDate                  : 2018:01:09 22:12:08+00:00
[File:System]   FileAccessDate                  : 2018:01:09 22:12:08+00:00
[File:System]   FileCreateDate                  : 2017:12:15 13:50:40+00:00
[EXIF:IFD0]     ModifyDate                      : 2018:01:04 09:55:03
[EXIF:ExifIFD]  DateTimeOriginal                : 2018:01:04 09:55:03
[EXIF:ExifIFD]  CreateDate                      : 2018:01:04 09:55:03
[MakerNotes:Sony] SonyDateTime                  : 2018:01:03 21:55:03
[EXIF:IFD1]     ModifyDate                      : 2018:01:03 21:55:03

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -ver
10.74


Quote from: Phil Harvey on January 09, 2018, 01:31:38 PM
QuoteWhy has ArtworkCircaDateCreated been assigned a value? It doesn't get a value if I use -wm w,  but is is being assigned by mistake?

This must be a list-type tag, for which (unfortunately) += is used to add a new value.

I would recommend this to change the MP4 date/times:

exiftool -quicktime:time:all+=12 DIR

Aha - so "append" works differently to "time shift": Time shifting will not create a tag if it did not already exist, but appending will, unless the write mode is "w", -wm w, write to existing tags only?

I am aiming for a single command to fix up all photos and video clips (before or after import from a camera memory card), so I think that exiftool -wm w time:all+=12 DIR is best to work with jpg, raw, and xmp, but still with risk of inadvertently adding a new list value if I encounter a file with an existing time related list tag.

Quote from: Phil Harvey on January 09, 2018, 01:31:38 PM
You're lucky that your local time zone is UTC, because then you don't have to worry about whether or not the QuickTimeUTC option is necessary when extracting these times.

I'll consider myself lucky when everything sorts in the right order :)

Phil Harvey

Quote from: busywait on January 09, 2018, 05:34:36 PM
Aha - so "append" works differently to "time shift": Time shifting will not create a tag if it did not already exist, but appending will, unless the write mode is "w", -wm w, write to existing tags only?

Yes.

QuoteI am aiming for a single command to fix up all photos and video clips (before or after import from a camera memory card), so I think that exiftool -wm w time:all+=12 DIR is best to work with jpg, raw, and xmp, but still with risk of inadvertently adding a new list value if I encounter a file with an existing time related list tag.

Sounds good.  Perhaps I should think about removing the list-type time tags from the "Time" group to avoid this problem.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Quote from: Phil Harvey on January 09, 2018, 09:46:06 PMSounds good.  Perhaps I should think about removing the list-type time tags from the "Time" group to avoid this problem.

In this particular case, I might think about doing so because this tag is a bit more than just a list type tag, isn't it?  It's a flattened structure tag, right?
* 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).

Phil Harvey

#5
OK, I have to think about this.  Below are all of the List-type Time tags.  Some of them clearly belong in the Time group and many are structure elements.  Perhaps I could do something like marking these tags as Unsafe for writing.

HTML-dc:Date
IPTC:ReferenceDate
Photoshop:LayerModifyDates
XMP-dc:Date
XMP-iptcExt:ArtworkCircaDateCreated
XMP-iptcExt:ArtworkDateCreated
XMP-iptcExt:PublicationEventDate
XMP-prism:OffSaleDateDate
XMP-prism:OnSaleDateDate
XMP-prism:PublicationDateDate
XMP-prism:PublicationDisplayDateDate
XMP-pur:EmbargoDate
XMP-pur:ExclusivityEndDate
XMP-pur:ExpirationDate
XMP-pur:OptionEndDate
XMP-xmpMM:HistoryWhen
XMP-xmpMM:IngredientsLastModifyDate
XMP-xmpMM:ManifestReferenceLastModifyDate
XMP-xmpMM:VersionsEventWhen
XMP-xmpMM:VersionsModifyDate


- Phil

Edit: ...but it seems that ArtworkCircaDateCreated is the only one that is written when all times were shifted by "12".  So maybe this is the only one we need to be concerned about.  The reason is that "12" is not a valid date/time, so it is rejected as a value when writing because all other date/time tags use date-time formatting, while the XMP specification states that ArtworkCircaDateCreated is just a text string.

I think I'll go ahead and mark this tag as "Unsafe" so that it won't be written when wildcards or "All" is used.  This should solve the problem.  I think this may be a better solution than removing it from the "Time" group.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

busywait

#6
Quote from: Phil Harvey on January 09, 2018, 09:46:06 PM
Sounds good.  Perhaps I should think about removing the list-type time tags from the "Time" group to avoid this problem.

That would help me in my current task, time-shifting files from a device with an unset clock. Perhaps there are other options?

  • Make a new shortcut like AllDates, perhaps called AllTimeStamps, that covers a wider range of create and modify tags?, so I could use exiftool -AllTimeStamps+=12
  • Make a more specific TimeStamps group in family 2, so I could use exiftool -TimeStamps:All+=12
  • Allow me to filter the tags returned by -Time:All to only scalar time values - I've no idea of likely syntax for that, but it would exclude TimeZone for example

Quote from: Phil Harvey on January 09, 2018, 01:31:38 PM
You're lucky that your local time zone is UTC, because then you don't have to worry about whether or not the QuickTimeUTC option is necessary when extracting these times.

I guess DST would still leave me seeing incorrect times sometimes anyway? Thanks for pointing out that option. For now I'm just fixing up the source data...

In my current batch of files the images were made in New Zealand, a 13 hour offset from home, and if I search against times I'll probably want to be searching in local time to find afternoon, evening, or night.

I've noticed that my Samsung cell phone recorded all mp4 video clip time stamps in UTC, as described at https://exiftool.org/TagNames/QuickTime.html. As far as I can tell, the file created and modified timestamps are local time. The other clue to local time is the GPS coordinate, because I had that turned on in the camera settings. The files do not contain a value for QuickTime:TimeZone. I'm not going to "fix" anything in these files, but it's a little annoying not to have any "local time" embedded in the file.

My Olympus Camera mostly does the opposite: All embedded timestamps are local (mostly consistent with the Olympus photo image files), and the file timestamps are local. However, while still image files (jpg and raw) include Olympus.DateTimeUTC in the maker notes - the video files do not have a UTC timestamp in the maker notes. Again, no TimeZone is recorded in the mp4 files.

(BTW, my camera does know local and UTC time - it sets them both each time I connect it to the OI.Share app on my phone. Until I connected it to the app DateTimeUTC was left blank.)

In general because files likely contain a mix of UTC and local times it's OK to time shift with Time:All, but probably not safe to assign times en-mass using Time:All.


busywait

Marking ArtworkCircaDateCreated as "unsafe for writing" sounds like it would avoid my script writing data in some unlikely situation - more likely it will help someone else in the future (hopefully not confuse them!). I definitely will be using -wm w to only write to existing tags in my scripts, which I'm confident will avoid any realistic problems in my usage.

To add to your comments above, some time shift strings could be valid dates. Also, there is a (super small) possibility that time-shifting backwards witih -= could remove existing data. See the sequence below (which deliberately does not use -wm w:


C:\Users\sjmac\src\ImageActionRunner\EXIF>:: Explore Time:All time shift behaviours

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -Time:All tester.mp4
File Modification Date/Time     : 2018:01:09 13:47:15+00:00
File Access Date/Time           : 2020:05:15 22:57:27+01:00
File Creation Date/Time         : 2020:05:15 22:57:32+01:00
Create Date                     : 2018:01:09 13:42:17
Modify Date                     : 2018:01:09 13:42:17
Track Create Date               : 2018:01:09 13:42:17
Track Modify Date               : 2018:01:09 13:42:17
Media Create Date               : 2018:01:09 13:42:17
Media Modify Date               : 2018:01:09 13:42:17
Track Create Date               : 2018:01:09 13:42:17
Track Modify Date               : 2018:01:09 13:42:17
Media Create Date               : 2018:01:09 13:42:17
Media Modify Date               : 2018:01:09 13:42:17

C:\Users\sjmac\src\ImageActionRunner\EXIF>"Time Add Offset From Prompt.bat" tester.mp4
Enter the Offset to add in YY:mm:dd HH:MM:SS (1 = 1 hour; 0:90 = 90 minutes; 0:0:120 = 120 seconds), or a blank line to do nothing and finish: 1:2:3 4:5:6

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -Time:All+="1:2:3 4:5:6" -FileCreateDate+="1:2:3 4:5:6" -FileModifyDate+="1:2:3 4:5:6" tester.mp4
======== tester.mp4 [1/1]
    1 image files updated

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -Time:All -G0:1 -s tester.mp4
[File:System]   FileModifyDate                  : 2019:03:12 17:52:21+00:00
[File:System]   FileAccessDate                  : 2019:03:12 17:52:21+00:00
[File:System]   FileCreateDate                  : 2021:07:19 03:02:38+01:00
[QuickTime]     CreateDate                      : 2019:03:12 17:47:23
[QuickTime]     ModifyDate                      : 2019:03:12 17:47:23
[QuickTime:Track1] TrackCreateDate              : 2019:03:12 17:47:23
[QuickTime:Track1] TrackModifyDate              : 2019:03:12 17:47:23
[QuickTime:Track1] MediaCreateDate              : 2019:03:12 17:47:23
[QuickTime:Track1] MediaModifyDate              : 2019:03:12 17:47:23
[QuickTime:Track2] TrackCreateDate              : 2019:03:12 17:47:23
[QuickTime:Track2] TrackModifyDate              : 2019:03:12 17:47:23
[QuickTime:Track2] MediaCreateDate              : 2019:03:12 17:47:23
[QuickTime:Track2] MediaModifyDate              : 2019:03:12 17:47:23
[XMP:XMP-iptcExt] ArtworkCircaDateCreated       : 1:2:3 4:5:6

C:\Users\sjmac\src\ImageActionRunner\EXIF>"Time Subtract Offset From Prompt.bat" tester.mp4
Enter the Offset to subtract in YYYY:mm:dd HH:MM:SS (1 = 1 hour; 0:90 = 90 minutes; 0:0:120 = 120 seconds), or a blank line to do nothing and finish: 1:2:3 4:5:6

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool" -Time:All-="1:2:3 4:5:6" -FileCreateDate-="1:2:3 4:5:6" -FileModifyDate-="1:2:3 4:5:6"  tester.mp4
======== tester.mp4 [1/1]
    1 image files updated

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -Time:All -G0:1 -s tester.mp4
[File:System]   FileModifyDate                  : 2018:01:09 13:47:15+00:00
[File:System]   FileAccessDate                  : 2018:01:09 13:47:15+00:00
[File:System]   FileCreateDate                  : 2020:05:15 22:57:32+01:00
[QuickTime]     CreateDate                      : 2018:01:09 13:42:17
[QuickTime]     ModifyDate                      : 2018:01:09 13:42:17
[QuickTime:Track1] TrackCreateDate              : 2018:01:09 13:42:17
[QuickTime:Track1] TrackModifyDate              : 2018:01:09 13:42:17
[QuickTime:Track1] MediaCreateDate              : 2018:01:09 13:42:17
[QuickTime:Track1] MediaModifyDate              : 2018:01:09 13:42:17
[QuickTime:Track2] TrackCreateDate              : 2018:01:09 13:42:17
[QuickTime:Track2] TrackModifyDate              : 2018:01:09 13:42:17
[QuickTime:Track2] MediaCreateDate              : 2018:01:09 13:42:17
[QuickTime:Track2] MediaModifyDate              : 2018:01:09 13:42:17

C:\Users\sjmac\src\ImageActionRunner\EXIF>"Time Add Offset From Prompt.bat" tester.mp4
Enter the Offset to add in YY:mm:dd HH:MM:SS (1 = 1 hour; 0:90 = 90 minutes; 0:0:120 = 120 seconds), or a blank line to do nothing and finish: 0001:02:03 04:05:06

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -Time:All+="0001:02:03 04:05:06" -FileCreateDate+="0001:02:03 04:05:06" -FileModifyDate+="0001:02:03 04:05:06" tester.mp4
======== tester.mp4 [1/1]
    1 image files updated

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -Time:All -G0:1 -s tester.mp4
[File:System]   FileModifyDate                  : 2019:03:12 17:52:21+00:00
[File:System]   FileAccessDate                  : 2019:03:12 17:52:21+00:00
[File:System]   FileCreateDate                  : 2021:07:19 03:02:38+01:00
[QuickTime]     CreateDate                      : 2019:03:12 17:47:23
[QuickTime]     ModifyDate                      : 2019:03:12 17:47:23
[QuickTime:Track1] TrackCreateDate              : 2019:03:12 17:47:23
[QuickTime:Track1] TrackModifyDate              : 2019:03:12 17:47:23
[QuickTime:Track1] MediaCreateDate              : 2019:03:12 17:47:23
[QuickTime:Track1] MediaModifyDate              : 2019:03:12 17:47:23
[QuickTime:Track2] TrackCreateDate              : 2019:03:12 17:47:23
[QuickTime:Track2] TrackModifyDate              : 2019:03:12 17:47:23
[QuickTime:Track2] MediaCreateDate              : 2019:03:12 17:47:23
[QuickTime:Track2] MediaModifyDate              : 2019:03:12 17:47:23
[XMP:XMP-iptcExt] ArtworkCircaDateCreated       : 0001:02:03 04:05:06
[XMP:XMP-iptcExt] ArtworkDateCreated            : 0001:02:03 04:05:06
[XMP:XMP-iptcExt] PublicationEventDate          : 0001:02:03 04:05:06
[XMP:XMP-dc]    Date                            : 0001:02:03 04:05:06
[XMP:XMP-prism] OffSaleDateDate                 : 0001:02:03 04:05:06
[XMP:XMP-prism] OnSaleDateDate                  : 0001:02:03 04:05:06
[XMP:XMP-prism] PublicationDateDate             : 0001:02:03 04:05:06
[XMP:XMP-prism] PublicationDisplayDateDate      : 0001:02:03 04:05:06
[XMP:XMP-pur]   EmbargoDate                     : 0001:02:03 04:05:06
[XMP:XMP-pur]   ExclusivityEndDate              : 0001:02:03 04:05:06
[XMP:XMP-pur]   OptionEndDate                   : 0001:02:03 04:05:06
[XMP:XMP-xmpMM] HistoryWhen                     : 0001:02:03 04:05:06
[XMP:XMP-xmpMM] IngredientsLastModifyDate       : 0001:02:03 04:05:06
[XMP:XMP-xmpMM] ManifestReferenceLastModifyDate : 0001:02:03 04:05:06
[XMP:XMP-xmpMM] VersionsEventWhen               : 0001:02:03 04:05:06
[XMP:XMP-xmpMM] VersionsModifyDate              : 0001:02:03 04:05:06

C:\Users\sjmac\src\ImageActionRunner\EXIF>"Time Subtract Offset From Prompt.bat" tester.mp4
Enter the Offset to subtract in YYYY:mm:dd HH:MM:SS (1 = 1 hour; 0:90 = 90 minutes; 0:0:120 = 120 seconds), or a blank line to do nothing and finish: 0001:02:03 04:05:06

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -Time:All-="0001:02:03 04:05:06" -FileCreateDate-="0001:02:03 04:05:06" -FileModifyDate-="0001:02:03 04:05:06" tester.mp4
======== tester.mp4 [1/1]
    1 image files updated

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -Time:All -G0:1 -s tester.mp4
[File:System]   FileModifyDate                  : 2018:01:09 13:47:15+00:00
[File:System]   FileAccessDate                  : 2018:01:09 13:47:15+00:00
[File:System]   FileCreateDate                  : 2020:05:15 22:57:32+01:00
[QuickTime]     CreateDate                      : 2018:01:09 13:42:17
[QuickTime]     ModifyDate                      : 2018:01:09 13:42:17
[QuickTime:Track1] TrackCreateDate              : 2018:01:09 13:42:17
[QuickTime:Track1] TrackModifyDate              : 2018:01:09 13:42:17
[QuickTime:Track1] MediaCreateDate              : 2018:01:09 13:42:17
[QuickTime:Track1] MediaModifyDate              : 2018:01:09 13:42:17
[QuickTime:Track2] TrackCreateDate              : 2018:01:09 13:42:17
[QuickTime:Track2] TrackModifyDate              : 2018:01:09 13:42:17
[QuickTime:Track2] MediaCreateDate              : 2018:01:09 13:42:17
[QuickTime:Track2] MediaModifyDate              : 2018:01:09 13:42:17

C:\Users\sjmac\src\ImageActionRunner\EXIF>exiftool -ver
10.74




Phil Harvey

Yes.  If you use a full shift format that has a 4-digit year, then you can get into trouble with the List-type tags.  I had realized this, but I don't think anyone will ever do this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).