photostructure / exiftool-vendored.js

Fast, cross-platform Node.js access to ExifTool
https://photostructure.github.io/exiftool-vendored.js/
MIT License
431 stars 43 forks source link

CreateDate for Videos #113

Closed mrbrahman closed 2 years ago

mrbrahman commented 2 years ago

Hi,

It seems CreateDate for video files is always in UTC across devices. At least that is my observation from a bunch of devices I have used (Samsung 2 and 9, Motorola phone, Samsung tablet, Nexus 5x, Pixel 4a 5g, iphone 12). I couldn't find a solid reference confirming this, but here are some of the links I could find.

https://www.photools.com/community/index.php?topic=10722.0 The creation time in videos is given in UTC - I think this is some kind of standard.

https://forums.androidcentral.com/ask-question/983495-why-doesnt-create-date-correspond-date-details-there-5-hour-difference.html

I see that exiftool-vendored is not adjusting CreateDate according to UTC. For e.g.

> var exiftool = require("exiftool-vendored")
> var e = exiftool.exiftool
> var p = await e.read("PXL_20220831_003137144.mp4")
undefined
> p.CreateDate
ExifDateTime {
  year: 2022,
  month: 8,
  day: 31,
  hour: 0,
  minute: 32,
  second: 6,
  millisecond: 0,
  tzoffsetMinutes: -240,
  rawValue: '2022:08:31 00:32:06',
  zoneName: 'America/New_York'
}
$ ll PXL_20220831_003137144.mp4
-rwxrwxrwx 1 mrbrahman mrbrahman 65950099 Aug 30 20:43 PXL_20220831_003137144.mp4

# created on Aug 30th, at 8:43 pm in local timezone (EST)

$ exiftool PXL_20220831_003137144.mp4
ExifTool Version Number         : 11.88
File Name                       : PXL_20220831_003137144.mp4
Directory                       : .
File Size                       : 63 MB
File Modification Date/Time     : 2022:08:30 20:43:55-04:00
File Access Date/Time           : 2022:08:30 20:43:55-04:00
File Inode Change Date/Time     : 2022:08:30 20:43:55-04:00
File Permissions                : rwxrwxrwx
File Type                       : MP4
File Type Extension             : mp4
MIME Type                       : video/mp4
Major Brand                     : MP4  Base Media v1 [IS0 14496-12:2003]
Minor Version                   : 2.0.0
Compatible Brands               : isom, iso2, mp41
Media Data Size                 : 65927282
Media Data Offset               : 44
Movie Header Version            : 0
Create Date                     : 2022:08:31 00:32:06
Modify Date                     : 2022:08:31 00:32:06
...
GPS Latitude                    : xx deg 26' xx.72" N
GPS Longitude                   : xx deg 30' xx.04" W
Rotation                        : 90
GPS Position                    : xx deg 26' xx.72" N, xx deg xx' xx.04" W

Is it possible to adjust CreateDate to UTC rather than just appending the timezone?

mceachen commented 2 years ago

Thanks for the well-written bug report!

Version 18.0.0 (which I just released) includes a new defaultVideosToUTC option that defaults to true, as I believe you're correct--videos seem to be mostly encoded in UTC.

Note that if any of the following tags have a valid value, even with videos, we'll use that instead: [ "TimeZone", "OffsetTime", "OffsetTimeOriginal", "OffsetTimeDigitized", "TimeZoneOffset" ].

If someone wants to skip the UTC default, they can set {defaultVideosToUTC: false} when creating their ExifTool singleton.

Thanks again!

mrbrahman commented 2 years ago

Thanks so much for the super fast fix!