How to handle UTC Dates in Movie Files from different sources

Started by sx8999, January 26, 2024, 02:55:45 AM

Previous topic - Next topic

sx8999

Hi all,

I want to organize my movie files (some already edited or transcoded in between, always while preserving metadata). I want to use the "local datetime" from the Metadata, both: To be used as -AllDates, as FileCreation/Modification Dates AND as well as filename. I've got a Batch for that, looks like this:

exiftool ^
    -m -overwrite_original_in_place -wm w ^
    -ext mp4 -ext mov ^
    -api QuickTimeUTC=1 ^
    "-AllDates<OldestDateTime" ^
    "-Track*Date<OldestDateTime" ^
    "-Media*Date<OldestDateTime" ^
    "-FileCreateDate<OldestDateTime" ^
    "-FileModifyDate<OldestDateTime" ^
    -Keys:CreationTime= ^
    -r "%dir%"

echo Renaming according to FileCreateDate
exiftool ^
    "-filename<${FileCreateDate}%%-c.%%ue" ^
    -d "%%Y%%m%%d_%%H%%M%%S" ^
    -p ^
    -r "%dir%"

For that, I use the CompositeTag OldestDateTime from here:
https://exiftool.org/forum/index.php?topic=7986.msg80801#msg80801

It seems to work SOMETIMES only - there seem to be various UTC Offset issues (probably in the files), so sometimes it works, sometimes it doesnt properly work.
My goal is simple: For all cases, the final filename shall be in the "Local" Timezone (i.e. the time it'd show on your smartphone in the local place). And all relevant Dates (ie -AllDates Tags) shall be correct w.r.t. it, so either in LocalTimezone or with UTC Offset - so that Tools like GooglePhotos or similarly get the "correct" Local Time)

Some examples:
1) Example which worked fine. Captured on Samsung S23:
One recorded video of my Android Phone while being in Thailand during Winter (UTC+7). My "Home" is usually Germany, which is UTC+1 in Winter.

Filename is 20231129_214400.MP4 (which is really the local datetime). Dates in the MP4 file are:

Recorded date                  : 2023-11-29T21:44:00+0100
Encoded date                  : UTC 2023-11-29 20:44:00
Tagged date                    : UTC 2023-11-29 20:44:00
major_brand                    : mp42
minor_version                  : 0
compatible_brands              : isommp42
creation_time                  : 2023-11-29T14:44:44.000000Z
location                      : +13.7591+100.4968/
location-eng                  : +13.7591+100.4968/

So the creation_time shows 14:44 which seems to be UTC. This one is ignord anyhow by ExifTool (and only supported since the very latest version). Recorded date shows UTC+1 (usual german timezone of my smartphone, even though I'm located in Thailand which is UTC+7). In the end, sending this file through my shown Batch WORKS!

2) Example which doesnt work fine. Captured on Samsung A52s, but transcoded via Handbrake without preserving metadata. Afterwards I set the Metadata by Exiftool again:

Now I have another file, captured in Summertime in germany, which is UTC+2 I think.
The Metadata is as following. UTC offset seems to be lost, most probable because I set -AllDates by Exiftool without specifying UTC offset!?

Format                        : MPEG-4
Format profile                : Base Media
Codec ID                      : isom (isom/iso2/mp41)
File size                      : 2.27 MiB
Duration                      : 40 s 234 ms
Overall bit rate              : 473 kb/s
Encoded date                  : UTC 2023-09-09 12:35:54
Tagged date                    : UTC 2023-09-09 12:35:54
major_brand                    : mp42
minor_version                  : 0
compatible_brands              : isommp42
location                      : +47.4036+010.4080/
location-eng                  : +47.4036+010.4080/
com.android.version            : 13
encoder                        : Lavf60.20.100

So the UTC+2 seems to be missing.
Everytime I send this file through my Batch, the dates (and therefore the filename) get shifted 2 hours earlier.
So I start with the shown data, filename is 20230909_123554.MP4, I send it through the shown Batchfile - afterwards all dates including the Filename will be 10:35:54. If I do it again, it'll be 08:35:54 etc... So something does not quite work here.


3) Example which doesnt work fine. Captured on iPhone. Original MOV-Files

Captured at 10:32:39h local Time.
Germany summertime, i..e UTC+2, which is also stored in the Quicktime Tag:

General
General
Complete name                  : IMG_5689.MOV
Format                        : MPEG-4
Format profile                : QuickTime
Codec ID                      : qt  0000.00 (qt  )
File size                      : 4.38 MiB
Duration                      : 2 s 970 ms
Overall bit rate              : 12.4 Mb/s
Encoded date                  : UTC 2020-09-25 08:32:39  << UTC Time obviously
Tagged date                    : UTC 2020-09-25 08:32:41
Writing library                : Apple QuickTime
com.apple.quicktime.live-photo : 1.000
com.apple.quicktime.live-photo : 1
com.apple.quicktime.make      : Apple
com.apple.quicktime.model      : iPhone 11 Pro
com.apple.quicktime.software  : 13.6.1
com.apple.quicktime.creationda : 2020-09-25T10:32:39+0200  <<<<<<<< UTC+2 is CORRECT

When running through my batch, I end up with a filename as 20200925_083239.MOV and the metadata as:

General
Complete name                  : 20200925_083239.MOV
Format                        : MPEG-4
Format profile                : QuickTime
Codec ID                      : qt  0000.00 (qt  )
File size                      : 4.38 MiB
Duration                      : 2 s 970 ms
Overall bit rate              : 12.4 Mb/s
Encoded date                  : UTC 2020-09-25 06:32:39 <<< SHIFTED -2 hours
Tagged date                    : UTC 2020-09-25 06:32:39 <<< SHIFTED -2 hours
Writing library                : Apple QuickTime
com.apple.quicktime.live-photo : 1
com.apple.quicktime.content.id : F3A8A818-662B-49A7-BC9E-CA23800F62BE
com.apple.quicktime.live-photo : 1.000
com.apple.quicktime.live-photo : 1
com.apple.quicktime.make      : Apple
com.apple.quicktime.model      : iPhone 11 Pro
com.apple.quicktime.software  : 13.6.1
[b]com.apple.quicktime.creationda : 2020-09-25T10:32:39+0200 <<< STILL CORRECT!!![/b]

Also for this file, when I run multiple times through my batch, it always get shifted -2 hours (like in Example 2). Even though this file is an ORIGINAL Iphone Captured file.

It does not Matter if I specify the parameter "-api QuickTimeUTC=1" or if I leave it out.

Is there any way to handle these files all the same and reaching my goal like I said above:

My goal is simple: For all cases, the final filename shall be in the "Local" Timezone (i.e. the time it'd show on your smartphone in the local place). And all relevant Dates (ie -AllDates Tags) shall be correct w.r.t. it, so either in LocalTimezone or with UTC Offset - so that Tools like GooglePhotos or similarly get the "correct" Local Time)

I hope it's just a simple fix and I forget a specific option in the Batch.

Thank you so much!

wywh

Quote from: sx8999 on January 26, 2024, 02:55:45 AMfinal filename shall be in the "Local" Timezone (i.e. the time it'd show on your smartphone in the local place). And all relevant Dates (ie -AllDates Tags) shall be correct w.r.t. it, so either in LocalTimezone or with UTC Offset - so that Tools like GooglePhotos or similarly get the "correct" Local Time)

I'd set the dates to local time with Keys:CreationDate (or UserData:DateTimeOriginal if your app prefers that) with the desired timezone. QuickTime:CreateDate uses UTC and that is more messy although using only that works in my workflow.

exiftool -a -G1 -s -fileOrder5 FileName -api LargeFileSupport=1 -api QuickTimeUTC=1 -FileCreateDate -Time:All 2001-0101-1200-00.mp4
[MacOS]         FileCreateDate                  : 2001:01:01 12:00:00-05:00
[QuickTime]     CreateDate                      : 2001:01:01 12:00:00-05:00
[UserData]      DateTimeOriginal                : 2001:01:01 12:00:00-05:00
[Keys]          CreationDate                    : 2001:01:01 12:00:00-05:00

I use the following command to copy filename to movie metadata dates (I dislike spaces in these filenames so I use 2001-0101-1200-00.mp4 format). I prefer not to generate any new date tags unless necessary so I use '-wm w' to prevent that. Sometimes I create Keys:CreationDate if the movie does not have it (newish iOS devices insert it by default).

exiftool -m -overwrite_original -wm w -api LargeFileSupport=1 -api QuickTimeUTC=1 '-AllDates<FileName' '-Track*Date<FileName' '-Media*Date<FileName' '-Keys:CreationDate<FileName' '-FileCreateDate<FileName' '-FileModifyDate<FileName' .
Some general and Mac-specific details at:

https://discussions.apple.com/docs/DOC-250002750

- Matti