Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video Create Date with GPS inferred timezone #156

Closed
jrasm91 opened this issue Sep 13, 2023 · 10 comments
Closed

Video Create Date with GPS inferred timezone #156

jrasm91 opened this issue Sep 13, 2023 · 10 comments

Comments

@jrasm91
Copy link

jrasm91 commented Sep 13, 2023

It does not seem possible to get a correct Create Date with a GPS inferred timezone for a video that is using UTC.

Example

File

$ exiftool PXL_20210906_174416840.mp4

Create Date                     : 2021:09:06 17:44:16
...
GPS Latitude                    : 33 deg 21' 11.16" N
GPS Longitude                   : 111 deg 51' 46.08" W
GPS Position                    : 33 deg 21' 11.16" N, 111 deg 51' 46.08" W

Options

const { exiftool } = require('exiftool-vendored');

async function test(filename, options) {
  const tags = await exiftool.read(filename, undefined, options);
  return {
    ...options,
    CreateDate: tags.CreateDate.toString(),
    tz: tags.tz,
  };
}

async function run() {
  const filename = 'File1.mp4';
  console.table([
    await test(filename, { defaultVideosToUTC: false, backfillTimezones: false, inferTimezoneFromDatestamps: false }),
    await test(filename, { defaultVideosToUTC: false, backfillTimezones: false, inferTimezoneFromDatestamps: true }),
    await test(filename, { defaultVideosToUTC: false, backfillTimezones: true, inferTimezoneFromDatestamps: false }),
    await test(filename, { defaultVideosToUTC: true, backfillTimezones: false, inferTimezoneFromDatestamps: false }),
    await test(filename, { defaultVideosToUTC: true, backfillTimezones: false, inferTimezoneFromDatestamps: true }),
    await test(filename, { defaultVideosToUTC: true, backfillTimezones: true, inferTimezoneFromDatestamps: false }),
    await test(filename, { defaultVideosToUTC: true, backfillTimezones: true, inferTimezoneFromDatestamps: true }),
  ]);
}

run().then(() => process.exit());

Results

(index) ...ToUTC backfill... infer... CreateDate tz
0 false false false '2021-09-06T17:44:16-07:00' 'America/Phoenix'
1 false false true '2021-09-06T17:44:16-07:00' 'America/Phoenix'
2 false true false '2021-09-06T17:44:16-07:00' 'America/Phoenix'
3 true false false '2021-09-06T17:44:16Z' 'UTC'
4 true false true '2021-09-06T17:44:16Z' 'UTC'
5 true true false '2021-09-06T17:44:16Z' 'UTC'
6 true true true '2021-09-06T17:44:16Z' 'UTC'
  • When defaultVideosToUTC is false, the timezone from GPS is correct, but the time is now wrong.
  • When defaultVideosToUTC is true, the timezone is time is correct, but the GPS timezone is not used.
  • The time and timezone is actually correct when using the file from CreateDate for Videos #113 and all three options set to true (has additional Creation Date with a timezone)

Expected Value

When defaultVideosToUTC is used with backfillTimezones and GPS data is available, I expected tz to be populated from GPS (America/Phoenix) and CreateDate to be adjusted for said timezone (2021-09-06T10:44:16-07:00).

@mceachen
Copy link
Member

mceachen commented Sep 13, 2023

Thanks for this research. Is this video metadata directly from a smartphone, or was it edited?

If you could attach all date and time fields coming from exiftool for that file, or just attach the file itself, that might be helpful for me to replicate your table.

(Fwiw, I would have expected defaultVideosToUTC: false, backfillTimezones: true to do what you wanted)

@jrasm91
Copy link
Author

jrasm91 commented Sep 13, 2023

It's directly from the phone. In general, I don't think any of the videos from my pixel phones have timezone information in them.

Here's the file: File1.zip

Here's *Date* properties:

jrasm91@jrasm91-ubuntu:Videos$ exiftool -*Date* File1.mp4 
File Modification Date/Time     : 2022:10:26 19:56:17-04:00
File Access Date/Time           : 2023:09:13 13:22:13-04:00
File Inode Change Date/Time     : 2023:09:13 13:21:46-04:00
Create Date                     : 2021:09:06 17:44:16
Modify Date                     : 2021:09:06 17:44:16
Track Create Date               : 2021:09:06 17:44:16
Track Modify Date               : 2021:09:06 17:44:16
Media Create Date               : 2021:09:06 17:44:16
Media Modify Date               : 2021:09:06 17:44:16
Full exif dump
ExifTool Version Number         : 12.40
File Name                       : File1.mp4
Directory                       : .
File Size                       : 4.7 MiB
File Modification Date/Time     : 2022:10:26 19:56:17-04:00
File Access Date/Time           : 2023:09:13 13:22:13-04:00
File Inode Change Date/Time     : 2023:09:13 13:21:46-04:00
File Permissions                : -rwxr-xr-x
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               : isom, mp42
Media Data Size                 : 4940337
Media Data Offset               : 40
Movie Header Version            : 0
Create Date                     : 2021:09:06 17:44:16
Modify Date                     : 2021:09:06 17:44:16
Time Scale                      : 10000
Duration                        : 2.97 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0
Audio Format                    : mp4a
Audio Channels                  : 2
Audio Bits Per Sample           : 16
Audio Sample Rate               : 48000
Matrix Structure                : 0 1 0 -1 0 0 0 0 1
Media Header Version            : 0
Media Create Date               : 2021:09:06 17:44:16
Media Modify Date               : 2021:09:06 17:44:16
Media Time Scale                : 90000
Media Duration                  : 0 s
Handler Type                    : NRT Metadata
Handler Description             : MetaHandle
Meta Format                     : mett
Image Size                      : 1024x768
Megapixels                      : 0.786
Avg Bitrate                     : 13.3 Mbps
GPS Latitude                    : 33 deg 21' 11.16" N
GPS Longitude                   : 111 deg 51' 46.08" W
Rotation                        : 90
GPS Position                    : 33 deg 21' 11.16" N, 111 deg 51' 46.08" W

mceachen added a commit that referenced this issue Sep 13, 2023
@mceachen
Copy link
Member

OK, I just checked the relevant code again, and these settings should indeed work.

Here's the validation spec:

22fe149

@mceachen
Copy link
Member

mceachen commented Sep 13, 2023

Ah -- I misread your expectations: you want both the timezone to default to UTC, and the timestamps to be shoved to Phoenix. Gotcha.

Poking the code with a stick now.

@jrasm91
Copy link
Author

jrasm91 commented Sep 13, 2023

Yeah, it's the combination of "don't mess up the timestamp because it is a video" and "please convert it from UTC to X using GPS"

@mceachen
Copy link
Member

mceachen commented Sep 13, 2023

Currently backfillTimezones is conservative: it doesn't set the time zone for ExifDateTime instances that already "have a zone".

Unfortunately, there isn't a discriminator for those ExifDateTime instances that are UTC because of #defaultToUTC, or because their raw value actually included a zone offset.

Edit: I just added the discriminator, so we can make this change safely now.

@mceachen
Copy link
Member

OK, I think this warrants a major release, as the output will be different for people using backfillTimezones.

@mceachen
Copy link
Member

Pushed. I'll release as soon as GHA validates the tests pass. Details here:

https://github.com/photostructure/exiftool-vendored.js/blob/main/CHANGELOG.md#v2300

fbabbce

@mceachen
Copy link
Member

released v23.0.0 🎉

@jrasm91
Copy link
Author

jrasm91 commented Sep 14, 2023

Perfect! Thank you for working on this an the fast turn around time. I just wanted to confirm that I've tested against v23 and everything is working as expected. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants