Changing FileModify Date to equal CreateDate results in incorrect, shifted date

Started by paddle, December 05, 2017, 06:52:30 PM

Previous topic - Next topic

paddle

Hello,

I have a folder of mp4, mov, and avi files. I need to set -FileModifyTime to equal -CreateDate (or -DateTimeOriginal for avi), using the command exiftool "-CreateDate>FileModifyDate" *.mp4.

The command runs fine, however resulting -FileModifyTime tags all are all either -6 or -5 hours from what they should be, displaying as YYYY:MM:DD HH:MM:SS-06:00

If they just displayed as YYYY:MM:DD HH:MM:SS they would be correct.

I realize this must be some kind of timezone shift. My computer is set to CST, which is UTC-6.

Does anyone have an idea how I can change this? Thanks!

Edit: I found this thread-- https://exiftool.org/forum/index.php?topic=5008.0-- that describes how to strip time zone from -DateTimeOriginal using exiftool "-fileModifyDate<${dateTimeOriginal;s/[-+].*//}" -ext mts -ext m2ts -ext mp4 -ext mov -ext mod %*, however this won't work in my case as -CreateDate and DateTimeOriginal are just in YYYY:MM:DD HH:MM:SS format, without the timezone offest.

StarGeek

You can't remove the timezone from FileModifyDate (or FileCreateDate/FileAccessDate) as this is controlled by the underlying OS.

For images, the timestamp metadata is assumed to be in the local time zone, so the addition of the timezone in FileModifyDate would be correct.  For videos, it's a whole different mess.  Certain timestamps are meant to be in UTC, but few cameras set it properly as they are not always gps aware.

If you wish to set FileModifyDate and adjust for the timezone, you can use something like:
"-FileModifyDate<${CreateDate}Z"
but FileModifyDate will then display as the time adjusted for the time zone.

Example:
C:\>exiftool -g1 -a -s -filemodifydate -exif:createdate y:\!temp\Test3.jpg
---- System ----
FileModifyDate                  : 2002:02:01 18:02:02-08:00
---- ExifIFD ----
CreateDate                      : 2017:12:05 17:56:45

C:\>exiftool -g1 -a -s "-FileModifyDate<${CreateDate}Z" y:\!temp\Test3.jpg
    1 image files updated

C:\>exiftool -g1 -a -s -filemodifydate -exif:createdate y:\!temp\Test3.jpg
---- System ----
FileModifyDate                  : 2017:12:05 09:56:45-08:00
---- ExifIFD ----
CreateDate                      : 2017:12:05 17:56:45


In this case, 2017:12:05 17:56:45 UTC and 2017:12:05 09:56:45-08:00 is the same 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).

paddle

Thanks, its good to know I can do that as well. Video files are really frustrating me.

The more I dig the more discrepancies I am finding. When I change the -fileModifyTime on *some* mp4's, it shows the correct time with the timezone shift (ie [-CreateDate+6]-6). However for all avi and mov, and most other mp4's it shows an incorrect -fileModifyTime, with just the -CreateDate-6:00.

Any recommendations? My goal is to have a unified DAM system through Digikam, but that is not looking very doable. As you said, pictures are easy, but videos on the other hand....
I do finally have correct DateTimeOriginal/CreateDate tags for all the video files now, however Digikam and other software read the -FileModifyDate as the capture date, and that is what is complicating things. (Interestingly enough Digikam reads the incorrect -FileModifyDate as correct, as it apparently doesn't incorporate timezone shift, but this doesn't help for the files that actually have the correct -FileModifyDate...)

My only thought is that I can change my system timezone to UTC 00:00:00, and then change the -FileModifyDate for all video files. Then it should not display timezone shift, correct?

paddle

OK. I tried running exiftool under UTC when I changed -fileModifyDate via export TZ=UTC. This worked to set the -fileModifyDate to YYYY:MM:DD HH:MM:SS+00:00. However, unless I change my whole system to UTC other applications are still reading the date as UTC-06:00.

Maybe I would be better off starting over and changing all CreateDate/DateTimeOriginal to local time zone time? Not sure if this is even possible with FFMPEG (which I used to set dates in the video files).

StarGeek

I can't really offer any advice here but certainly interested in what you come up with.  Video files are a pain all around.

I am very interested in the ffmpeg command you're using to set dates.  Ffmpeg confuses the heck out of me.
* 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).

paddle

I'm not sure what I'm going to do yet. For now I may have to put up with some incorrect sorting in Digikam for video files.

Regarding changing dates with ffmpeg I just wrote a simple bash script that extracts the -quicktime:createdate tag from video files, parses it into a date that can be used with ffmpeg, and then changes all the dates with ffmpeg. -quicktime:createdate is one of the few video tags that exiftool can write, so this enables the great batch capabilities of exiftool to be used with the power of ffmpeg. I am by no means very proficient at either tools, but this was the best way I came up with to batch change video metadata dates. I'll post the script here in case its useful to someone.

#!/bin/sh

for i in `ls *.MP4`   #change extension accordingly
do
    echo "$i"
    VAR=$(exiftool -s -s -s -quicktime:createdate "$i")
    echo $VAR
    VAR2=$(echo $VAR | sed 's/2014:\(.*\):\(.*\) \(.*\):\(.*\):\(.*\)/2014-\1-\2 \3:\4:\5/'          #all the dates I needed to change were in 2014 so I was lazy here, but you could edit for it to work on any year
   )
    echo $VAR2
    ffmpeg -i "$i" -map 0 -c copy -metadata creation_time="$VAR2" "${i%.*}.mp4"     #for *.avi change "creation_time" to "ICRD"
done