Rename raw files using DateTimeOriginal minus ExposureTime

Started by NYC_Timescape, March 06, 2023, 03:00:30 PM

Previous topic - Next topic

NYC_Timescape

Hello!  I am 8 years into shooting a 30 Year long timelapse of NYC - 1 image every 30 seconds... currently tweaking my homemade Arduino Intervaolmeter because I want the images to capture exactly on the 00 and 30. 

I've got the intervalometer firing beautifully on the 00s and 30s - but I'm struggling because my Sony a7s apparently logs the DateTimeOriginal as when the shutter closes - instead of when it opens. 

As a solution I am trying to figure out if when I rename the files I could name them as (DateTimeOriginal Minus Exposure Time) but I can not find the correct way to write the code. 

I have searched the forums carefully - I found one astronomer with a similar problem - but the answer for him isn't suitable for my project. 

My trouble is my files will be named ...00, ...30, ...00, ...30 all day long until night time when my exposures go beyond 1 second.  So I drift to 31, 45, etc.  *This creates a separate problem for file-handlers on my machine that automatically upload to AWS every 15 mins to populate my website https://www.nyctimescape.com/

This is my working code just to rename by DateTimeOriginal:

/usr/local/bin/exiftool '-FileName<DateTimeOriginal' -d %Y-%m-%d\ %H.%M.%S.ARW /Users/JDiMac/Desktop/RAWTEST/RAWcapture/


This is one of my many attempts to subtract the Exposure Time from the dateTimeOriginal.  I wonder would I first need to convert Exposure time into an integer? 


/usr/local/bin/exiftool '-DateTimeOriginal-= -ExposureTime' '-FileName<DateTimeOriginal' -d %Y-%m-%d\ %H.%M.%S.ARW /Users/JDiMac/Desktop/RAWTEST/RAWcapture/

I am a bit lost and I appreciate ANY and all guidance!  Thank you - Joe

StarGeek

Try this
C:\>exiftool -G1 -a -s -DateTimeOriginal -ExposureTime y:\!temp\Test4.jpg
[ExifIFD]      DateTimeOriginal                : 2023:03:07 12:00:15
[ExifIFD]      ExposureTime                    : 15

C:\>exiftool -P -overwrite_original "-DateTimeOriginal-<0:0:$ExposureTime#" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -DateTimeOriginal -ExposureTime y:\!temp\Test4.jpg
[ExifIFD]      DateTimeOriginal                : 2023:03:07 12:00:00
[ExifIFD]      ExposureTime                    : 15

The hashtag is used to make sure ExposureTime uses the raw value instead of listing fractions (see the -n (--printConv) option).  Fractional exposure times won't affect the result here, as subseconds are held in a different tag.
* 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).

NYC_Timescape

#2
StarGeek thank you SO MUCH for your quick, perfect, thoughtful response! 

I forgot to mention I am using exiftool on my Mac OS 11.6.8, in an automator folder action.


After some thorough testing of the solution you sent me I am getting the wrong result on a very small amount of files (10/3000) I'm getting a result that is off by 1 second.  So the filename should be 00 seconds but it is 01 seconds or sometimes 59 seconds. 


It usually happens when the camera shutter is 2.5 or 3.2 seconds long.   I think it must be happening because ExposureTime includes 1 decimal place (2.5, 3.2) and filemodifydate does not contain any decimal places. 




I have been trying to write code that incorporates subseconds of filemodifydate but it seems that might not be possible. 


Do you have any ideas how I can resolve this? 


thank you SO MUCH!

Phil Harvey

This is a little bit tricky because Composite date/time tags are not shiftable.  But you can do this using the advanced formatting feature and the ShiftTime() helper function:

> exiftool a.jpg "-*datetimeoriginal*" -exposuretime -s -a -G1
[ExifIFD]       DateTimeOriginal                : 2022:05:20 15:05:02
[Composite]     SubSecDateTimeOriginal          : 2022:05:20 15:05:02.10+00:00
[ExifIFD]       ExposureTime                    : 0.3
[Canon]         ExposureTime                    : 0.3
> exiftool a.jpg '-subsecdatetimeoriginal<${subsecdatetimeoriginal;ShiftTime("-0:0:".$self->GetValue("ExposureTime","ValueConv"))}'
    1 image files updated
> exiftool a.jpg "-*datetimeoriginal*" -exposuretime -s -a -G1
[ExifIFD]       DateTimeOriginal                : 2022:05:20 15:05:01
[Composite]     SubSecDateTimeOriginal          : 2022:05:20 15:05:01.80+00:00
[ExifIFD]       ExposureTime                    : 0.3
[Canon]         ExposureTime                    : 0.3

This will work for any EXIF tag where the corresponding sub-second tag exists.  It won't work for filesystem date/times because these don't have sub-second information.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

NYC_Timescape

Hi Phil - Thank you SO MUCH for your insight and for taking the time!!

I am a HUGE fan and having your help really made my day!!!


For this project I am working with four Sony a7s cameras - I didn't realize but it seems the a7s does not store any subseconds.  My apologies I should have known.


I realized a possible solution - if I could just disregard anything beyond the decimal point of the -exposuretime I think that would solve my problem. 

Since DateTimeOriginal doesn't have subseconds it is technically always rounding down right?  So I could just ignore the subseconds of the exposure time I think everything would even out.


Would you agree? 



I found this forum showing how to omit anything beyond to 2 decimal places but I can't figure out how to get to zero decimal places.

Quote from: StarGeek on August 18, 2019, 04:38:00 PMIt can be done, but the procedure might depend upon the rest of your command.

The code to be used would be $_=sprintf('FMT',$_) where FMT is a perl printf style format string.  I believe that perl printf has a few differences than other types of printf, such as C, so if you want to do something other than the round to decimal place that I detail below, you might have to be careful.

To global round to 2 decimal places, you would add this to your command
-api "filter=$_=sprintf('%.2f',$_)"
Though this will have problems if your command is dealing with tags that aren't just numbers.

To edit specific tags, as in your example of copying to Keywords, you would do something like this
"-Keywords<${GPSSpeed;$_=sprintf('%.2f',$_)}"
 


Phil Harvey

Quote from: NYC_Timescape on March 17, 2023, 09:19:58 AMSince DateTimeOriginal doesn't have subseconds it is technically always rounding down right?

This depends entirely on how you set the camera clock.  Usually they aren't accurate at this level.  But if the clock was set exactly, then yes, the seconds would be effectively rounded down.

QuoteI found this forum showing how to omit anything beyond to 2 decimal places but I can't figure out how to get to zero decimal places.

You could try this:

-api "filter=$_=int($_)"

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).