0

I'm using Drew's metadata-extractor library to rename my photos and videos.

It's fantastic, but I'm encountering a major problem when renaming, for example videos, when I'm on another time zone than when the one when the video was shot.

e.g. My video was taken in Argentina, with the datetime  "Fri Mar 27 11:43:25 ART 2020".

When I want to process my file, back in europe, all the dates I can find within the Metadata have been adapted to CET , i.e. "Fri Mar 27 15:43:25 CET 2020".

Therefore, I can't use those datetimes to rename my files, as it will result in an incorrect name. I cannot mannually change the timezone for each directory I'm processing, as the idea it to automate everything.

Is there a way to get the original datetime/timezone from my files ? (mp4, jpg, ... all types of  images/videos).

Many thanks.

Frank

F.doe
  • 376
  • 1
  • 4
  • 7

1 Answers1

2

This is a common problem, and doesn't have anything to do with the library you are asking about, but rather with how your camera recorded the timestamp to begin with.

Many cameras don't have time zone functionality at all. Others store UTC time in the EXIF data so the photos align with a point in time regardless of time zone. Of those that do, some store the time zone offset and some do not.

Ultimately, if the only information in the file captured by your camera is a UTC-based timestamp, then there's not much you can do to recover the original time zone - unless you happen to know it.

Fortunately in your case, you know you were in Argentina, and thus you can take a UTC-based timestamp from the output of the metadata extractor library (there should be one in there, but you'll have to look for it). Then you can convert that to Argentina time (use "America/Buenos_Aires" as the time zone id in your Java code).

There are plenty of examples of how to convert from UTC to a specific time zone already, so I won't include one here. You can find many if you search for that specific problem.

I'll also point out that some cameras store the latitude and longitude of where the image was taken, so even if you were traveling all over the world, you could use such information to derive the time zone identifier.

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575