Camera Manufacturers: Please Use Accurate Time Stamps for Image Files

My Canon and Nikon cameras use either the exFAT file system or the (older) FAT file system for image storage on their SD, SDxx, CF, CFexpress or XQD cards. In theory, the exFAT file system supports accurate time stamps up to a precision of 10 milliseconds. The FAT32 file system, in contrast, just offers 2 second accuracy for the modification time, or 10 millisecond for the creation time.

Unfortunately Canon has decided to cripple the time stamp accuracy down to a 1 second resolution. (I can’t speak for Sony or other manufacturers as I haven’t used their cameras recently.) Nikon’s VFAT format makes it even more difficult to get precise time information. But why should this matter?

Why Accurate Time Stamps?

Today’s digital cameras are capable of shooting at ever increasing frame rates. For DSLRs 5-10 frames per second is the norm, mirrorless cameras reach 20, 30, or even 120 frames per second. In such cases sorting the images by the time they were taken won’t necessarily show you the correct order.

Displaying Photos in the Sequence They Were Taken

When the camera writes images to a memory card, it gives the image a name and a 3 or 4 digit sequence number. When sorting by file name, the image files will appear in the order they were taken. But when the counter reaches the maximum number, it restarts from 0 or 1. This can can cause problems when sorting files by names.

These are relatively minor issues, since the file names with their sequence number still allow you to determine the proper sequence. But what if you rename photos?

I typically rename photos on import and try to give them a more meaningful name:

Jaffa_NIKON D850_20220430_002.NEF

In the above example I used the location name. The photos on a memory card may have come from different locations. Or sometimes I change the naming scheme, i.e. to the name of a person instead of a location, or some other identifier.

When using different naming schemes in the same folder, sorting by name does not guarantee that the pictures will appear in the order I shot them. But most people will be able to live with that. For example, Adobe Lightroom (LR) normally displays photos in the order they were taken.

Timestamps and Heuristics

The real problems appear when using the time stamp to help identify a file. Recently I wrote a script that creates checksums (hashes) of all my files. Another script uses these hashes to check if files have become corrupted (which tends to happen from time to time).

I wanted to avoid recalculating hashes when files have been renamed or moved, so long as the content of the files hasn’t changed. Unfortunately there seems to be no easy way to accomplish the task. In the end I decided to use file modification time and file size as the two criteria that – when used together – can uniquely identify a file. (There is a little more to it, but let’s keep it simple.)

Here an example of the file modification time, the size (in bytes), and the pathname:

2022-05-06+09:55:59.0000000000	41879126	./Lightroom/heiko/2022/2022-05-06/Tel Aviv_Canon EOS R5_20220506_199.CR3
2022-05-06+09:56:04.0000000000	42432086	./Lightroom/heiko/2022/2022-05-06/Tel Aviv_Canon EOS R5_20220506_200.CR3
2022-05-06+09:56:05.0000000000	43032150	./Lightroom/heiko/2022/2022-05-06/Tel Aviv_Canon EOS R5_20220506_201.CR3
2022-05-06+09:56:20.0000000000	44434518	./Lightroom/heiko/2022/2022-05-06/Tel Aviv_Canon EOS R5_20220506_202.CR3

The above Canon EOS R5 image files, originally stored on an exFAT file system, do not offer accurate file modification times. Likewise the Nikon NEF files below:

[[email protected]]$ ls --full-time
-rw-r----- 1 heiko heiko 53939124 2022-04-30 11:11:24.000000000 +0300 'Jaffa_NIKON D850_20220430_153.NEF'
-rw-r----- 1 heiko heiko 53913732 2022-04-30 11:11:24.000000000 +0300 'Jaffa_NIKON D850_20220430_154.NEF'
-rw-r----- 1 heiko heiko 53829517 2022-04-30 11:11:28.000000000 +0300 'Jaffa_NIKON D850_20220430_155.NEF'

My use of the file modification time for identifying renamed or moved files is by no means an isolated case. Backup programs use similar heuristics to identify file name or location changes. A common use case for time stamps is in digital forensics.

How to Ensure Accurate Time Stamps

GPS and/or SIM

Unlike the most primitive cell phone, cameras normally do not keep an accurate track of the time. You need to manually enter the date and time as well as the time zone. Since the camera clock is usually not synced with a time server, the clock will drift – several seconds a month, sometimes minutes.

The are two ways to ensure accurate time: via the Internet or cell phone network if the camera has Wifi or a SIM card and access to a mobile network. Or the more traditional way by using a GPS module.

Some manufacturers offer a GPS module as an add-on. There are also third party GPS units but you will have to ensure that they are capable of syncing the time with the camera AND that they indeed are able to provide an accurate time stamp. This also depends on the file system used, as mentioned before.

Integrating a GPS receiver would greatly simplify time keeping and accuracy, so would the addition of a SIM card. Another benefit of adding these features to a camera is theft protection, as advocated for example on Tony & Chelsey Northrup’s YouTube channel.

Adding a SIM and thus turning the camera into a “cellphone” allows you to share photos quickly and easily. Whether you are a professional shooting sports, a photojournalist, or you just want to share your latest photos on social media, this is the fastest and simplest way.

File System

The first thing you need to do is to check which file system your camera is using. Here is an example of a XQD card formatted in the Nikon D850 camera:

[[email protected]]$ sudo file -sL /dev/sdf1
/dev/sdf1: DOS/MBR boot sector, code offset 0x3e+2, OEM-ID "NIKON5.0", Bytes/sector 2048, sectors/cluster 16, Media descriptor 0xf8, sectors/track 63, heads 255, hidden sectors 2016, sectors 53147680 (volumes > 32 MB), FAT (32 bit), sectors/FAT 7168, reserved 0x1, serial number 0, label: "NIKON D850 "

In the above example, I plugged the card reader with the XQD card into my Linux host. /dev/sdf1 is the partition on the XQD card holding the photos. As you can see, the Nikon D850 formats the memory card using the FAT32 file system. That is bad! As I explained earlier, the FAT32 file system offers a modify time stamp accuracy down to 2 seconds.

Let’s examine an image file:

[[email protected]]$ stat _D856581.NEF 
  File: _D856581.NEF
  Size: 51488079  	Blocks: 100608     IO Block: 32768  regular file
Device: 8,81	Inode: 1914        Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   heiko)   Gid: ( 1000/   heiko)
Access: 2022-05-13 03:00:00.000000000 +0300
Modify: 2022-05-01 22:26:20.000000000 +0300
Change: 2022-05-01 22:26:20.500000000 +0300
 Birth: -

But wait – what is the .5 fraction in the “Change” time stamp field? This field tells you the time when the metadata has changed, not the file content. According to a paper on file system forensics, there is even a difference between copying files and using copy/paste:

According to Lee (2015), if we copy a file from a FAT system to a NTFS system it will keep the same modified date but will change the create date and time to the current time. Where Lee (2015) notes if the file is cut and pasted it will keep the same modified date and time and will keep the creation date the same as before.

Filesystem Timestamps: What Makes Them Tick?” by Tony Knutson

My Canon EOS R5 uses the exFAT file system, which on paper supports 10 ms modification time accuracy, but didn’t implement it properly:

[[email protected]]$ stat _97A0810.CR3 
  File: _97A0810.CR3
  Size: 51386454  	Blocks: 100608     IO Block: 131072 regular file
Device: 8,81	Inode: 1983        Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/   heiko)   Gid: ( 1000/   heiko)
Access: 2022-05-08 16:00:40.000000000 +0300
Modify: 2022-05-08 16:00:41.000000000 +0300
Change: 2022-05-08 16:00:41.000000000 +0300
 Birth: 2022-05-08 16:00:41.000000000 +0300

No luck with the Canon EOS R5 either, at least not with the current firmware 1.5.2.

While exFAT is definitely the better choice when it comes to file systems for memory cards, it’s far from optimal. Luckily Microsoft opened the exFAT specs in 2019 for use in the open source community. Before that it was proprietary, which explains why Nikon chose FAT32 for the D850 (and other cameras).

Generally an open source file system would almost always be the better choice, providing camera vendors with access to source code and often better documentation.

Summary

Cameras writing accurate time stamps along with their image files simplify image sorting and processing. When backing up or archiving photos, accurate time stamps allow applications to use heuristic methods to identify moved or renamed files.

In addition to these benefits, accurate timestamps open new possibilities. For instance you could use a series of photos to determine the speed of a moving subject (e.g. cyclist, etc.). Imagine a sports photographer using a simple application to determine the speed of an athlete by evaluating two consecutive photos.

Author: Heiko Sieger

The day has 24 hours. If that isn't enough, I also use the night.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.