Updating the metadata of video timestamps using exiftool
I have a Sony a7c and Sony RX 100 M3. Both of these cameras when recording videos seem to disregard the timezone settings and just use UTC time. Whenever I import these videos to digikam which is the software I use to manage my photos, the sorting gets messed up as the times of the videos are not synced with the photos which has the correct local time with timezone.
In digikam there is a setting to adjust the date and time but it does not seem to edit the video metadata itself. I’m using digikam version 8.0.0 on Linux Mint 20. It does update only locally in digikam. If you upload your videos to other software or to the cloud, the original incorrect timestamp is retained. So here are some commands to use in exiftool
to modify the metadata directly on the video file.
Check all the available metadata with date in its name
exiftool myvideo.mp4 | grep -i date
Sample output
File Modification Date/Time : 2024:01:02 18:47:47+08:00
File Access Date/Time : 2024:01:02 18:47:45+08:00
File Inode Change Date/Time : 2024:01:02 18:47:58+08:00
Create Date : 2023:06:17 03:30:04
Modify Date : 2023:06:17 03:30:04
Track Create Date : 2023:06:17 03:30:04
Track Modify Date : 2023:06:17 03:30:04
Media Create Date : 2023:06:17 03:30:04
Media Modify Date : 2023:06:17 03:30:04
Last Update : 2023:06:17 11:30:04+08:00
Creation Date Value : 2023:06:17 11:30:04+08:00
If there’s one metadata field that has the correct timestamp based on how you know when the video was taken or based on the generated thumbnail photo of that video, then use that field to copy to the other timestamp fields. In Sony a7c, the Creation Date Value
seems to be the correct field, so we use that to copy over its value to the other timestmap fields. The fields to update are the Create Date
, Modify Date
, Track Create Date
, Track Modify Date
, Media Create Date
, and Media Modify Date
.
To update all timestamp metadata of all mp4 files in the current directory to use the Creation Date Value
exiftool '-mediacreatedate<creationdatevalue' '-mediamodifydate<creationdatevalue' '-createdate<creationdatevalue' '-modifydate<creationdatevalue' '-trackcreatedate<creationdatevalue' '-trackmodifydate<creationdatevalue' -ext mp4 .
In the exiftool
command above, the less than sign means it will copy over the value of the field on the right to the field on the left. The dash -
indicates the field to use and the -ext
means the extension file to update. Then the .
of course refers to the current directory.
Lastly, exiftool
generates a backup with _original
suffix. After you’ve verified the metadata update, you can delete this backup with the -delete_original
option.
To delete the _original
copies
exiftool -delete_original -ext mp4 .
Learn more about exiftool
here.