Retain original creation date in 2 step video workflow?

Started by Peter Cablist, December 29, 2022, 12:35:27 PM

Previous topic - Next topic

Peter Cablist

Hi all,
I have started using exiftool just today, spent a couple of hours getting accustomed to the usage.

I have some family photos and videos in Apple Photos that I want to edit, compress and share via my Synology (the Synology Photos app introduced in DSM7). To get the files sorted by date, Synology Photos reads one of the date fields in the video's exif, but this gets changed during my edit-compress workflow. I am trying to find out if exiftool can help.

This is my workflow:
Processing-step 1:
shoot video on iOS device and sync to iCloud Photos. Sample video was shot on nov 13th 2022.
Processing-step 2:
on MacBook, open Photos app, select video, trim + adjust and export to disk, on dec 28th 2022.

+--+ at this point the exported file's exif shows the following date records:
File Modification Date/Time    : 2022:12:29 00:46:58+01:00
File Access Date/Time          : 2022:12:29 17:19:35+01:00
File Inode Change Date/Time    : 2022:12:29 17:19:33+01:00
---
Create Date                    : 2022:12:28 23:46:57 [video exported from Apple Photos]
Modify Date                    : 2022:12:28 23:46:58
---
Track Create Date              : 2022:12:28 23:46:57
Track Modify Date              : 2022:12:28 23:46:58
---
Media Create Date              : 2022:12:28 23:46:57
Media Modify Date              : 2022:12:28 23:46:58
---
Creation Date                  : 2022:11:13 10:59:02+01:00 [video recorded]


When I import this file into Synology Photos I get the wrong date sorting (December)

From the exif manual I composed the following exif command:

Exiftool step A: exiftool -overwrite_original "-alldates<creationdate" DIR

After this, the Create Date and Modify Date fields are changed to nov 13th and moved downward in the exif, to just below the Creation Date field and XMP Toolkit:
Create Date                    : 2022:11:13 10:59:02+01:00
Modify Date                    : 2022:11:13 10:59:02+01:00
Date/Time Original              : 2022:11:13 10:59:02+01:00


The file now imports correctly in Synology Photos at the correct creation date sorting position.

Hurray!!
Not so fast, the video file is too big, I need another processing step:

Processing-step 3:
Compress the video file in Handbrake, output format mp4 by H264 process.

+--+ at this point the exif shows the following date records:
File Modification Date/Time    : 2022:12:29 16:44:20+01:00
File Access Date/Time          : 2022:12:29 17:41:20+01:00
File Inode Change Date/Time    : 2022:12:29 16:45:02+01:00

Create Date                    : 2022:12:29 15:44:17
Modify Date                    : 2022:12:29 15:44:17

Track Create Date              : 2022:12:29 15:44:17
Track Modify Date              : 2022:12:29 15:44:17

Media Create Date              : 2022:12:29 15:44:17
Media Modify Date              : 2022:12:29 15:44:17


So the original creation date is not carried over by Handbrake and their forum shows they're not going to implement it anytime soon.

o o o - - - Idea 1 - - - o o o
All I can think of now is to write the 20221113 date into the filename in the first "exiftool step A" and then add a second exiftool step to write that date back into the Handbrake'd file's appropriate date field(s).

For that last step I phrased:
Exiftool step C: exiftool -overwrite_original "-alldates<filename" DIR. This works well, it yields correct date ordering in Synology Photos.

But how do I get this date into the filename, as an APPEND (not REPLACE) to the filename?
So input file:
"G-IMG_7762_from_Apple_Photos_Exiffed_HB.mp4"
Desired result:
"20221113-103001-G-IMG_7762_from_Apple_Photos_Exiffed_HB.mp4"
So I want to add "YYmmdd_HHMMSS_" before the filename.

o o o - - - Idea 2 - - - o o o
If you should have a better idea how to achieve the same objective, I'd be all ears.

Thank you.

StarGeek

One important thing to take note of is that EXIF is not a generic term.  It is a very specific type of metadata.  All EXIF data is metadata, but not all metadata is EXIF data.  This distinction is important, as I detail below.

Also, you would want to use the command in FAQ #3 so you see all tags, including duplicates, and the groups they belong to.  This will allow you to know if a tag is in the EXIF group or the Quicktime group.  If you want to list just the time related tags, you would use
exiftool -time:all -G1 -a -s /path/to/files/

The simplest thing to do would be to copy all the data from the original videos into the new ones.  Assuming they have the same names but are in different directories
exiftool -TagsFromFile /path/to/Source/%f.%e -All:All /path/to/files/

This will copy all the tags in the original to the exact same locations in the new videos.

But, there is something you need to be aware of.  Depending upon how the video was created, there could be a lot of data which cannot be copied at all.  For example, some cameras and phones will put actual EXIF data in a video file.  The problem is that there is not a standard to do so.  The result is that every camera company does so in different ways.  There's a similar problem with GPS/Gyro data in a video file. 

So when you recompress a file with Handbrake, all this EXIF/GPS/Gyro data will be lost and cannot be copied from the original. This is why you need to know if the data you are looking at is EXIF or something else.  It will allow you to decide if this data is important enough to keep or will be lost.

Another thing to keep in mind is that most of the time stamps in a video file are supposed to be set to UTC, with CreationDate and DateTimeOriginal being exceptions.  So when you list the time data from a file and it's not in UTC, then the programs that read the data correctly, such as the Windows/Mac OS, it won't appear correctly.  I don't know what data your Synology  is reading, so you'll have to test it and decide.

Exiftool can automatically correct the time to UTC when writing if you add the -api QuickTimeUTC option.

To address your rename, you would use a command like this
exiftool -d "%Y%m%d_%H%M%S_%%f.%%e" "-Filename<CreationDate" /path/to/files/

See -d (-dateFormat) option for details about that, for details on the %%f and %%e variables, and Common Date Format Codes for full list of the date codes.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Peter Cablist

Thank you so much for your elaborate writeup!

I ran the exiftool -a -G1 -s DIR command. The CreationDate field is in [Keys]:

[Keys]          CreationDate                    : 2022:11:13 11:00:40+01:00

With the rename code you provide I could close the gap and now my videos live happily in Synology Photos with correct date sorting. My condensed workflow now is:
- Export video's from Apple Photos (e.g. "IMG_7762.mov")
- Exiftool fix AllDates from CreationDate
- Exiftool rename so creation date is in filename (e.g. "20221113_105902_IMG_7762.mov")
- Shrink size using Handbrake
- Exiftool fix AllDates from filename
- import into Synology Photos

After two days of tinkering this is a very quick way to process the photos, all steps batch mode.

So for this project I have not needed to dive into the Exiftool manual any deeper, thanks to your help. Next time I will reread your reply.

Peter